summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java11
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java7
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java61
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java12
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java10
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java9
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java7
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java8
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java6
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java5
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java6
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java3
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java7
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java2
-rw-r--r--adapters/mso-vfc-adapter/pom.xml190
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java98
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java29
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java9
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java45
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java34
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java26
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java19
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java5
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java225
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy160
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java491
28 files changed, 1181 insertions, 312 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java
index fd252b634a..3aa77c2c7a 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentEntry.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +27,12 @@ import java.util.HashSet;
import java.util.ArrayList;
import java.util.Set;
import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
+import org.openecomp.mso.logger.MsoLogger;
public class MsoHeatEnvironmentEntry {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
private Set<MsoHeatEnvironmentParameter> parameters = null;
private Set<MsoHeatEnvironmentResource> resources = null;
private StringBuilder rawEntry = null;
@@ -48,7 +52,7 @@ public class MsoHeatEnvironmentEntry {
private void processRawEntry() {
try {
- if (this.rawEntry == null || this.rawEntry.equals(""))
+ if (this.rawEntry == null || "".equals(this.rawEntry))
return;
byte[] b = this.rawEntry.toString().getBytes();
MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(b);
@@ -61,6 +65,7 @@ public class MsoHeatEnvironmentEntry {
this.resourceRegistryEntryRaw = sb;
}
} catch (Exception e) {
+ LOGGER.debug("Exception:", e);
this.valid = false;
this.errorString = e.getMessage();
//e.printStackTrace();
@@ -97,13 +102,13 @@ public class MsoHeatEnvironmentEntry {
public void addParameter(MsoHeatEnvironmentParameter hep) {
if (this.parameters == null) {
- this.parameters = new HashSet<MsoHeatEnvironmentParameter>();
+ this.parameters = new HashSet<>();
}
this.parameters.add(hep);
}
public void addResource(MsoHeatEnvironmentResource her) {
if (this.resources == null) {
- this.resources = new HashSet<MsoHeatEnvironmentResource>();
+ this.resources = new HashSet<>();
}
this.resources.add(her);
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
index f5dffc3297..31e2fca4c1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatEnvironmentResource.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +21,12 @@
package org.openecomp.mso.openstack.utils;
-
+import org.openecomp.mso.logger.MsoLogger;
public class MsoHeatEnvironmentResource {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
private String name;
private String value;
@@ -77,7 +80,7 @@ public class MsoHeatEnvironmentResource {
try {
result = this.name.hashCode();
} catch (Exception e) {
- // in case it's null - return zero
+ LOGGER.debug("Exception:", e);
}
return result;
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
index 8073c953e9..fad0c2368b 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoHeatUtils.java
@@ -91,12 +91,12 @@ public class MsoHeatUtils extends MsoCommonUtils {
// token will be used until it expires.
//
// The cache key is "tenantId:cloudId"
- private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <String, HeatCacheEntry> ();
+ private static Map <String, HeatCacheEntry> heatClientCache = new HashMap <> ();
// Fetch cloud configuration each time (may be cached in CloudConfig class)
protected CloudConfig cloudConfig;
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
protected MsoJavaProperties msoProps = null;
@@ -343,7 +343,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
if (haveFiles && haveHeatFiles) {
// Let's do this here - not in the bean
LOGGER.debug ("Found files AND heatFiles - combine and add!");
- Map <String, Object> combinedFiles = new HashMap <String, Object> ();
+ Map <String, Object> combinedFiles = new HashMap <> ();
for (String keyString : files.keySet ()) {
combinedFiles.put (keyString, files.get (keyString));
}
@@ -584,7 +584,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
}
} // end while !deleted
- StringBuilder errorContextMessage = null;
+ StringBuilder errorContextMessage;
if (createTimedOut) {
errorContextMessage = new StringBuilder("Stack Creation Timeout");
} else {
@@ -737,7 +737,14 @@ public class MsoHeatUtils extends MsoCommonUtils {
String canonicalName = heatStack.getStackName () + "/" + heatStack.getId ();
try {
- OpenStackRequest <Void> request = heatClient.getStacks ().deleteByName (canonicalName);
+ OpenStackRequest <Void> request = null;
+ if(null != heatClient) {
+ request = heatClient.getStacks ().deleteByName (canonicalName);
+ }
+ else {
+ LOGGER.debug ("Heat Client is NULL" );
+ }
+
executeAndRecordOpenstackRequest (request, msoProps);
} catch (OpenStackResponseException e) {
if (e.getStatus () == 404) {
@@ -845,7 +852,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
OpenStackRequest <Stacks> request = heatClient.getStacks ().list ();
Stacks stacks = executeAndRecordOpenstackRequest (request, msoProps);
- List <StackInfo> stackList = new ArrayList <StackInfo> ();
+ List <StackInfo> stackList = new ArrayList <> ();
// Not sure if returns an empty list or null if no stacks exist
if (stacks != null) {
@@ -859,7 +866,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
if (e.getStatus () == 404) {
// Not sure if this can happen, but return an empty list
LOGGER.debug ("queryAllStacks - stack not found: ");
- return new ArrayList <StackInfo> ();
+ return new ArrayList <> ();
} else {
// Convert the OpenStackResponseException to an MsoOpenstackException
throw heatExceptionToMsoException (e, QUERY_ALL_STACKS);
@@ -891,7 +898,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
HeatTemplate heatTemplate) throws IllegalArgumentException {
// Check that required parameters have been supplied for this template type
String missingParams = null;
- List <String> paramList = new ArrayList <String> ();
+ List <String> paramList = new ArrayList <> ();
// TODO: Enhance DB to support defaults for Heat Template parameters
@@ -913,8 +920,8 @@ public class MsoHeatUtils extends MsoCommonUtils {
}
// Remove any extraneous parameters (don't throw an error)
- Map <String, Object> updatedParams = new HashMap <String, Object> ();
- List <String> extraParams = new ArrayList <String> ();
+ Map <String, Object> updatedParams = new HashMap <> ();
+ List <String> extraParams = new ArrayList <> ();
for (String key : inputParams.keySet ()) {
if (!paramList.contains (key)) {
// This is not a valid parameter for this template
@@ -1139,7 +1146,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
* This may be useful if cached credentials get out of sync.
*/
public static void heatCacheReset () {
- heatClientCache = new HashMap <String, HeatCacheEntry> ();
+ heatClientCache = new HashMap <> ();
}
public Map<String, Object> queryStackForOutputs(String cloudSiteId,
@@ -1273,7 +1280,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
sb.append("(outputs is empty)");
return sb;
}
- Map<String, Object> outputs = new HashMap<String,Object>();
+ Map<String, Object> outputs = new HashMap<>();
for (Output outputItem : outputList) {
outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue());
}
@@ -1419,7 +1426,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
} else {
cdl3 = cdl2;
}
- ArrayList<String> list = new ArrayList<String>(Arrays.asList(cdl3.split(",")));
+ ArrayList<String> list = new ArrayList<>(Arrays.asList(cdl3.split(",")));
return list;
}
@@ -1441,9 +1448,9 @@ public class MsoHeatUtils extends MsoCommonUtils {
* @return HashMap<String, Object> of the inputs, cleaned and converted
*/
public HashMap<String, Object> convertInputMap(Map<String, String> inputs, HeatTemplate template) {
- HashMap<String, Object> newInputs = new HashMap<String, Object>();
- HashMap<String, HeatTemplateParam> params = new HashMap<String, HeatTemplateParam>();
- HashMap<String, HeatTemplateParam> paramAliases = new HashMap<String, HeatTemplateParam>();
+ HashMap<String, Object> newInputs = new HashMap<>();
+ HashMap<String, HeatTemplateParam> params = new HashMap<>();
+ HashMap<String, HeatTemplateParam> paramAliases = new HashMap<>();
if (inputs == null) {
LOGGER.debug("convertInputMap - inputs is null - nothing to do here");
@@ -1462,7 +1469,7 @@ public class MsoHeatUtils extends MsoCommonUtils {
for (HeatTemplateParam htp : template.getParameters()) {
LOGGER.debug("Adding " + htp.getParamName());
params.put(htp.getParamName(), htp);
- if (htp.getParamAlias() != null && !htp.getParamAlias().equals("")) {
+ if (htp.getParamAlias() != null && !"".equals(htp.getParamAlias())) {
LOGGER.debug("\tFound ALIAS " + htp.getParamName() + "->" + htp.getParamAlias());
paramAliases.put(htp.getParamAlias(), htp);
}
@@ -1485,20 +1492,20 @@ public class MsoHeatUtils extends MsoCommonUtils {
}
}
String type = params.get(key).getParamType();
- if (type == null || type.equals("")) {
+ if (type == null || "".equals(type)) {
LOGGER.debug("**PARAM_TYPE is null/empty for " + key + ", will default to string");
type = "string";
}
LOGGER.debug("Parameter: " + key + " is of type " + type);
- if (type.equalsIgnoreCase("string")) {
+ if ("string".equalsIgnoreCase(type)) {
// Easiest!
String str = inputs.get(key);
if (alias)
newInputs.put(realName, str);
else
newInputs.put(key, str);
- } else if (type.equalsIgnoreCase("number")) {
- String integerString = inputs.get(key).toString();
+ } else if ("number".equalsIgnoreCase(type)) {
+ String integerString = inputs.get(key);
Integer anInteger = null;
try {
anInteger = Integer.parseInt(integerString);
@@ -1518,8 +1525,8 @@ public class MsoHeatUtils extends MsoCommonUtils {
else
newInputs.put(key, integerString);
}
- } else if (type.equalsIgnoreCase("json")) {
- String jsonString = inputs.get(key).toString();
+ } else if ("json".equalsIgnoreCase(type)) {
+ String jsonString = inputs.get(key);
JsonNode jsonNode = null;
try {
jsonNode = new ObjectMapper().readTree(jsonString);
@@ -1539,8 +1546,8 @@ public class MsoHeatUtils extends MsoCommonUtils {
else
newInputs.put(key, jsonString);
}
- } else if (type.equalsIgnoreCase("comma_delimited_list")) {
- String commaSeparated = inputs.get(key).toString();
+ } else if ("comma_delimited_list".equalsIgnoreCase(type)) {
+ String commaSeparated = inputs.get(key);
try {
ArrayList<String> anArrayList = this.convertCdlToArrayList(commaSeparated);
if (alias)
@@ -1554,8 +1561,8 @@ public class MsoHeatUtils extends MsoCommonUtils {
else
newInputs.put(key, commaSeparated);
}
- } else if (type.equalsIgnoreCase("boolean")) {
- String booleanString = inputs.get(key).toString();
+ } else if ("boolean".equalsIgnoreCase(type)) {
+ String booleanString = inputs.get(key);
Boolean aBool = new Boolean(booleanString);
if (alias)
newInputs.put(realName, aBool);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
index 4e715fa06e..bd649e867f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java
@@ -36,9 +36,12 @@ import java.util.LinkedHashMap;
import org.yaml.snakeyaml.Yaml;
+import org.openecomp.mso.logger.MsoLogger;
public class MsoYamlEditorWithEnvt {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
private Map <String, Object> yml;
private Yaml yaml = new Yaml ();
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@@ -65,6 +68,7 @@ public class MsoYamlEditorWithEnvt {
try {
resourceMap = (Map<String,Object>) yml.get("parameters");
} catch (Exception e) {
+ LOGGER.debug("Exception:", e);
return paramSet;
}
if (resourceMap == null) {
@@ -90,6 +94,7 @@ public class MsoYamlEditorWithEnvt {
try {
value = JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
+ LOGGER.debug("Exception:", e);
value = "_BAD_JSON_MAPPING";
}
} else {
@@ -104,7 +109,7 @@ public class MsoYamlEditorWithEnvt {
}
public synchronized Set <MsoHeatEnvironmentResource> getResourceListFromEnvt() {
try {
- Set<MsoHeatEnvironmentResource> resourceList = new HashSet<MsoHeatEnvironmentResource>();
+ Set<MsoHeatEnvironmentResource> resourceList = new HashSet<>();
@SuppressWarnings("unchecked")
Map<String, Object> resourceMap = (Map<String,Object>) yml.get("resource_registry");
Iterator<Entry <String,Object>> it = resourceMap.entrySet().iterator();
@@ -118,12 +123,12 @@ public class MsoYamlEditorWithEnvt {
}
return resourceList;
} catch (Exception e) {
-
+ LOGGER.debug("Exception:", e);
}
return null;
}
public synchronized Set <HeatTemplateParam> getParameterList () {
- Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> ();
+ Set <HeatTemplateParam> paramSet = new HashSet <> ();
@SuppressWarnings("unchecked")
Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters");
Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator ();
@@ -137,6 +142,7 @@ public class MsoYamlEditorWithEnvt {
try {
value = resourceEntry.get ("default");
} catch (java.lang.ClassCastException cce) {
+ LOGGER.debug("Exception:", cce);
// This exception only - the value is an integer. For what we're doing
// here - we don't care - so set value to something - and it will
// get marked as not being required - which is correct.
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java
index 0b62be6dd0..d9b09fa1b0 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkRequestCommon.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,11 +30,13 @@ import javax.xml.bind.Marshaller;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
+import org.openecomp.mso.logger.MsoLogger;
/**
* Everything that is common between all Network Requests.
*/
public abstract class NetworkRequestCommon {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
private Boolean skipAAI = false;
private String messageId;
private String notificationUrl;
@@ -63,7 +66,7 @@ public abstract class NetworkRequestCommon {
}
public boolean isSynchronous() {
- return notificationUrl == null || (notificationUrl != null && notificationUrl.isEmpty());
+ return notificationUrl == null || (notificationUrl.isEmpty());
}
public String toJsonString() {
@@ -73,7 +76,7 @@ public abstract class NetworkRequestCommon {
mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE);
jsonString = mapper.writeValueAsString(this);
} catch (Exception e) {
- // ignore
+ LOGGER.debug("Exception:", e);
}
return jsonString;
}
@@ -87,8 +90,7 @@ public abstract class NetworkRequestCommon {
marshaller.marshal(this, bs);
return bs.toString();
} catch (Exception e) {
- // Shouldn't happen...
- e.printStackTrace();
+ LOGGER.debug("Exception:", e);
return "";
}
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java
index 40d2aba1c8..56ec73d94a 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/NetworkResponseCommon.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,12 +30,13 @@ import javax.xml.bind.Marshaller;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
-
+import org.openecomp.mso.logger.MsoLogger;
/**
* Everything that is common between all Volume Group Responses, except for QueryVolumeGroupResponse.
*/
public abstract class NetworkResponseCommon {
private String messageId;
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
public NetworkResponseCommon() {
messageId = null;
@@ -59,7 +61,7 @@ public abstract class NetworkResponseCommon {
mapper.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE);
jsonString = mapper.writeValueAsString(this);
} catch (Exception e) {
- // ignore
+ LOGGER.debug("Exception:", e);
}
return jsonString;
}
@@ -73,8 +75,7 @@ public abstract class NetworkResponseCommon {
marshaller.marshal(this, bs);
return bs.toString();
} catch (Exception e) {
- // Shouldn't happen...
- e.printStackTrace();
+ LOGGER.debug("Exception:", e);
return "";
}
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java
index 418a15abf2..1ca36aface 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/QueryNetworkResponse.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +32,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.map.ObjectMapper;
import org.jboss.resteasy.annotations.providers.NoJackson;
+import org.openecomp.mso.logger.MsoLogger;
@XmlRootElement(name = "queryNetworkResponse")
@NoJackson
@@ -44,6 +46,7 @@ public class QueryNetworkResponse {
private List<String> routeTargets;
private Map<String, String> subnetIdMap;
private Map<String, String> networkOutputs;
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
public QueryNetworkResponse() {
super();
@@ -138,7 +141,9 @@ public class QueryNetworkResponse {
ObjectMapper mapper = new ObjectMapper();
jsonString = mapper.writeValueAsString(this);
}
- catch (Exception e) {}
+ catch (Exception e) {
+ LOGGER.debug("Exception:", e);
+ }
return jsonString;
}
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java
index ed10540491..09c1b3ee38 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/nwrest/UpdateNetworkRequest.java
@@ -32,6 +32,7 @@ import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import org.jboss.resteasy.annotations.providers.NoJackson;
import org.codehaus.jackson.map.annotate.JsonRootName;
+import org.openecomp.mso.logger.MsoLogger;
@JsonRootName("updateNetworkRequest")
@XmlRootElement(name = "updateNetworkRequest")
@@ -50,9 +51,10 @@ public class UpdateNetworkRequest extends NetworkRequestCommon {
private ProviderVlanNetwork providerVlanNetwork;
private ContrailNetwork contrailNetwork;
private Boolean backout = true;
- private Map<String,String> networkParams = new HashMap<String, String>();
+ private Map<String,String> networkParams = new HashMap<>();
private MsoRequest msoRequest = new MsoRequest();
-
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
public UpdateNetworkRequest() {
super();
}
@@ -129,7 +131,7 @@ public class UpdateNetworkRequest extends NetworkRequestCommon {
try {
this.networkTechnology = NetworkTechnology.valueOf(networkTechnology.toUpperCase());
} catch (IllegalArgumentException e) {
- // ignore
+ LOGGER.debug("Exception:", e);
}
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java
index 2cf5ca2638..9b9c214129 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCEvent.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +37,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.openecomp.mso.logger.MsoLogger;
// NOTE: the JAXB (XML) annotations are required with JBoss AS7 and RESTEasy,
// even though we are using JSON exclusively. The @NoJackson annotation
@@ -61,6 +63,8 @@ import java.util.Map;
@NoJackson
public class SDNCEvent implements Serializable {
private static final long serialVersionUID = 1L;
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
// Event type
private String eventType;
@@ -143,7 +147,7 @@ public class SDNCEvent implements Serializable {
mapper.setSerializationInclusion(Inclusion.NON_NULL);
return mapper.writeValueAsString(this);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.debug("Exception:", e);
throw new UnsupportedOperationException("Cannot convert "
+ getClass().getSimpleName() + " to JSON", e);
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java
index 4a756aeccd..45609168ee 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCRequestCommon.java
@@ -28,12 +28,15 @@ import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import javax.xml.bind.annotation.XmlElement;
import java.io.IOException;
import java.io.Serializable;
+import org.openecomp.mso.logger.MsoLogger;
/**
* Base class for all SDNC adapter requests.
*/
public abstract class SDNCRequestCommon implements Serializable {
private static final long serialVersionUID = 1L;
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
// Endpoint on which BPMN can receive notifications from the SDNC adapter.
private String bpNotificationUrl;
@@ -101,7 +104,7 @@ public abstract class SDNCRequestCommon implements Serializable {
mapper.setSerializationInclusion(Inclusion.NON_NULL);
return mapper.writeValueAsString(this);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.debug("Exception:", e);
throw new UnsupportedOperationException("Cannot convert "
+ getClass().getSimpleName() + " to JSON", e);
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java
index f141116aeb..5e6b9394a6 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/sdncrest/SDNCResponseCommon.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,12 +28,15 @@ import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import javax.xml.bind.annotation.XmlElement;
import java.io.IOException;
import java.io.Serializable;
+import org.openecomp.mso.logger.MsoLogger;
/**
* Base class for all SDNC adapter responses, including errors.
*/
public abstract class SDNCResponseCommon implements Serializable {
private static final long serialVersionUID = 1L;
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
// Identifies the MSO transaction with SDNC.
private String sdncRequestId;
@@ -109,7 +113,7 @@ public abstract class SDNCResponseCommon implements Serializable {
mapper.setSerializationInclusion(Inclusion.NON_NULL);
return mapper.writeValueAsString(this);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.debug("Exception:", e);
throw new UnsupportedOperationException("Cannot convert "
+ getClass().getSimpleName() + " to JSON", e);
}
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java
index 75668143e2..aa6af56082 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/openecomp/mso/adapters/vnfrest/VfRequestCommon.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,7 +46,7 @@ public abstract class VfRequestCommon extends VfResponseCommon {
}
public boolean isSynchronous() {
- return notificationUrl == null || (notificationUrl != null && notificationUrl.isEmpty());
+ return notificationUrl == null || notificationUrl.isEmpty();
}
// getMessageId, setMessageId, toJsonString, toJsonString are all defined in VfResponseCommon.
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
index 7fe8892ee8..6c7d584f6d 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,6 +74,7 @@ public abstract class CatalogQuery {
jsonString = mapper.writeValueAsString(this);
}
catch (Exception e) {
+ LOGGER.debug("Exception:", e);
LOGGER.debug ("jsonString exception:"+e.getMessage());
jsonString = "invalid"; //throws instead?
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java
index 2407581f55..9f709140ec 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,9 +26,11 @@ import org.codehaus.jackson.map.SerializationConfig;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import java.io.ByteArrayOutputStream;
+import org.openecomp.mso.logger.MsoLogger;
public abstract class CatalogQueryExceptionCommon {
private String messageId;
+ protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
public CatalogQueryExceptionCommon() { messageId = null; }
public CatalogQueryExceptionCommon(String messageId) { this.messageId = messageId; }
@@ -43,7 +46,7 @@ public abstract class CatalogQueryExceptionCommon {
jsonString = mapper.writeValueAsString(this);
return jsonString;
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.debug ("Exception:", e);
return "";
}
}
@@ -57,7 +60,7 @@ public abstract class CatalogQueryExceptionCommon {
marshaller.marshal(this, bs);
return bs.toString();
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.debug ("Exception:", e);
return "";
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
index f687aca683..3ffb0c6744 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModules.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,6 +75,7 @@ public class QueryVfModules {
LOGGER.debug ("QueryVfModules jsonString: "+jsonString);
}
catch (Exception e) {
+ LOGGER.debug ("Exception:", e);
LOGGER.debug ("QueryVfModules jsonString exception:"+e.getMessage());
}
return jsonString;
diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml
index 4f049c350f..fcf0682ca5 100644
--- a/adapters/mso-vfc-adapter/pom.xml
+++ b/adapters/mso-vfc-adapter/pom.xml
@@ -1,89 +1,94 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.openecomp.so</groupId>
- <artifactId>adapters</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </parent>
- <groupId>org.openecomp.so.adapters</groupId>
- <artifactId>mso-vfc-adapter</artifactId>
- <packaging>war</packaging>
- <name>mso-vfc-adapter</name>
- <description>Web service endpoint for vfc operations</description>
-
- <!-- <properties> -->
- <!-- <project.build.sourceEncoding/> -->
- <!-- <project.reporting.outputEncoding/> -->
- <!-- </properties> -->
-
- <build>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <warSourceDirectory>WebContent</warSourceDirectory>
- <failOnMissingWebXml>false</failOnMissingWebXml>
- <attachClasses>true</attachClasses>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-web-api</artifactId>
- <version>6.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so.adapters</groupId>
- <artifactId>mso-adapter-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so.adapters</groupId>
- <artifactId>mso-adapters-rest-interface</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.spec.javax.ejb</groupId>
- <artifactId>jboss-ejb-api_3.2_spec</artifactId>
- <version>1.0.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.ejb3</groupId>
- <artifactId>jboss-ejb3-ext-api</artifactId>
- <version>2.2.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>status-control</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.so</groupId>
- <artifactId>mso-requests-db</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>adapters</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.openecomp.so.adapters</groupId>
+ <artifactId>mso-vfc-adapter</artifactId>
+ <packaging>war</packaging>
+ <name>mso-vfc-adapter</name>
+ <description>Web service endpoint for vfc operations</description>
+ <!-- <properties> -->
+ <!-- <project.build.sourceEncoding/> -->
+ <!-- <project.reporting.outputEncoding/> -->
+ <!-- </properties> -->
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <warSourceDirectory>WebContent</warSourceDirectory>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <!--<dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-web-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>-->
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so.adapters</groupId>
+ <artifactId>mso-adapter-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so.adapters</groupId>
+ <artifactId>mso-adapters-rest-interface</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.2_spec</artifactId>
+ <version>1.0.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>2.2.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>status-control</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>mso-requests-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.19</version>
@@ -101,5 +106,16 @@
<version>1.19</version>
<scope>test</scope>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.22.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
index 1be5bab1c3..438393bc35 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcAdapterRest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc;
import javax.servlet.http.HttpServletRequest;
@@ -29,6 +30,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
+import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException;
import org.openecomp.mso.adapters.vfc.model.NSResourceInputParameter;
import org.openecomp.mso.adapters.vfc.model.NsOperationKey;
import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
@@ -44,7 +46,7 @@ import org.openecomp.mso.logger.MsoLogger;
* </p>
*
* @author
- * @version ONAP Amsterdam Release 2017-08-28
+ * @version ONAP Amsterdam Release 2017-08-28
*/
@Path("/v1/vfcdrivers")
public class VfcAdapterRest {
@@ -53,6 +55,10 @@ public class VfcAdapterRest {
private final VfcManager driverMgr = new VfcManager();
+ public VfcAdapterRest() {
+
+ }
+
/**
* Create a NS
* <br>
@@ -67,12 +73,16 @@ public class VfcAdapterRest {
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response createNfvoNs(HttpServletRequest servletReq) {
// Step 1: get parameters from request for current node
- String body = RestfulUtil.getRequestBody(servletReq);
- ValidateUtil.assertObjectNotNull(body);
- LOGGER.debug("body from request is {}" + body);
- NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class);
- RestfulResponse rsp = driverMgr.createNs(nsInput);
- return buildResponse(rsp);
+ try {
+ String body = RestfulUtil.getRequestBody(servletReq);
+ ValidateUtil.assertObjectNotNull(body);
+ LOGGER.debug("body from request is {}" + body);
+ NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class);
+ RestfulResponse rsp = driverMgr.createNs(nsInput);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ return e.buildErrorResponse();
+ }
}
/**
@@ -87,14 +97,17 @@ public class VfcAdapterRest {
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response deleteNfvoNs(HttpServletRequest servletReq, @PathParam("nsInstanceId") String nsInstanceId) {
- // Step 1: get parameters from request for current node
- String body = RestfulUtil.getRequestBody(servletReq);
- ValidateUtil.assertObjectNotNull(body);
- LOGGER.debug("body from request is {}" + body);
- NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class);
-
- RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId);
- return buildResponse(rsp);
+ try {
+ // Step 1: get parameters from request for current node
+ String body = RestfulUtil.getRequestBody(servletReq);
+ ValidateUtil.assertObjectNotNull(body);
+ LOGGER.debug("body from request is {}" + body);
+ NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class);
+ RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ return e.buildErrorResponse();
+ }
}
/**
@@ -102,7 +115,7 @@ public class VfcAdapterRest {
* <br>
*
* @param servletReq The Http Request
- * @param jobId The job id
+ * @param jobId The job id
* @return
* @since ONAP Amsterdam Release
*/
@@ -111,15 +124,19 @@ public class VfcAdapterRest {
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response queryNfvoJobStatus(HttpServletRequest servletReq, @PathParam("jobId") String jobId) {
- ValidateUtil.assertObjectNotNull(jobId);
- String body = RestfulUtil.getRequestBody(servletReq);
- ValidateUtil.assertObjectNotNull(body);
- LOGGER.debug("body from request is {}" + body);
- NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class);
- RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
- return buildResponse(rsp);
- }
+ try {
+ ValidateUtil.assertObjectNotNull(jobId);
+ String body = RestfulUtil.getRequestBody(servletReq);
+ ValidateUtil.assertObjectNotNull(body);
+ LOGGER.debug("body from request is {}" + body);
+ NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class);
+ RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ return e.buildErrorResponse();
+ }
+ }
/**
* Instantiate NS instance
@@ -136,11 +153,15 @@ public class VfcAdapterRest {
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response instantiateNfvoNs(HttpServletRequest servletReq, @PathParam("nsInstanceId") String nsInstanceId) {
String body = RestfulUtil.getRequestBody(servletReq);
- ValidateUtil.assertObjectNotNull(body);
- LOGGER.debug("body from request is {}" + body);
- NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class);
- RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput);
- return buildResponse(rsp);
+ try {
+ ValidateUtil.assertObjectNotNull(body);
+ LOGGER.debug("body from request is {}" + body);
+ NSResourceInputParameter nsInput = JsonUtil.unMarshal(body, NSResourceInputParameter.class);
+ RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ return e.buildErrorResponse();
+ }
}
/**
@@ -157,16 +178,19 @@ public class VfcAdapterRest {
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response terminateNfvoNs(HttpServletRequest servletReq, @PathParam("nsInstanceId") String nsInstanceId) {
- ValidateUtil.assertObjectNotNull(nsInstanceId);
- String body = RestfulUtil.getRequestBody(servletReq);
- ValidateUtil.assertObjectNotNull(body);
- LOGGER.debug("body from request is {}" + body);
- NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class);
- RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId);
- return buildResponse(rsp);
+ try {
+ ValidateUtil.assertObjectNotNull(nsInstanceId);
+ String body = RestfulUtil.getRequestBody(servletReq);
+ ValidateUtil.assertObjectNotNull(body);
+ LOGGER.debug("body from request is {}" + body);
+ NsOperationKey nsOperationKey = JsonUtil.unMarshal(body, NsOperationKey.class);
+ RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId);
+ return buildResponse(rsp);
+ } catch(ApplicationException e) {
+ return e.buildErrorResponse();
+ }
}
-
/**
* build response from restful response
* <br>
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
index 171949aa8e..f4572c8351 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
@@ -71,6 +71,9 @@ public class VfcManager {
nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
}
+ public VfcManager(){
+
+ }
/**
* create network service
* <br>
@@ -79,10 +82,10 @@ public class VfcManager {
* @return
* @since ONAP Amsterdam Release
*/
- public RestfulResponse createNs(NSResourceInputParameter segInput) {
+ public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException {
// Step1: get service template by node type
- String nsdId = segInput.getNsOperationKey().getNodeTemplateId();
+ String nsdId = segInput.getNsOperationKey().getNodeTemplateUUID();
// nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id"
LOGGER.info("serviceTemplateId is {}, id is {}", nsdId);
@@ -94,8 +97,8 @@ public class VfcManager {
// Step3: Prepare restful parameters and options
NsCreateReq oRequest = new NsCreateReq();
oRequest.setNsdId(nsdId);
- oRequest.setNsName(segInput.getSubServiceName());
- oRequest.setDescription(segInput.getSubServiceDesc());
+ oRequest.setNsName(segInput.getNsServiceName());
+ oRequest.setDescription(segInput.getNsServiceDescription());
String createReq = JsonUtil.marshal(oRequest);
// Step4: Call NFVO or SDNO lcm to create ns
@@ -119,7 +122,7 @@ public class VfcManager {
// Step 6: save resource operation information
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(
segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(),
- segInput.getNsOperationKey().getNodeTemplateId());
+ segInput.getNsOperationKey().getNodeTemplateUUID());
nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
@@ -143,7 +146,7 @@ public class VfcManager {
* @return
* @since ONAP Amsterdam Release
*/
- public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) {
+ public RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException{
LOGGER.info("delete ns -> begin");
// Step1: prepare url and methodType
String url = getUrl(nsInstanceId, CommonConstant.Step.DELETE);
@@ -156,7 +159,7 @@ public class VfcManager {
LOGGER.info("delete ns response content is : {}", deleteRsp.getResponseContent());
LOGGER.info("delete ns -> end");
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(),
- nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId());
+ nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
if(!HttpCode.isSucess(deleteRsp.getStatus())) {
LOGGER.error("fail to delete ns");
@@ -190,7 +193,7 @@ public class VfcManager {
* @return
* @since ONAP Amsterdam Release
*/
- public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) {
+ public RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput) throws ApplicationException{
// Call the NFVO or SDNO service to instantiate service
LOGGER.info("instantiate ns -> begin");
@@ -215,7 +218,7 @@ public class VfcManager {
String jobId = rsp.get(CommonConstant.JOB_ID);
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(
segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(),
- segInput.getNsOperationKey().getNodeTemplateId());
+ segInput.getNsOperationKey().getNodeTemplateUUID());
if(ValidateUtil.isStrEmpty(jobId)) {
LOGGER.error("Invalid jobId from instantiate operation");
nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
@@ -254,11 +257,11 @@ public class VfcManager {
* @return
* @since ONAP Amsterdam Release
*/
- public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) {
+ public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException{
// Step1: save segment operation info for delete process
LOGGER.info("save segment operation for delete process");
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(),
- nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId());
+ nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
nsOperInfo.setStatus(RequestsDbConstant.Status.PROCESSING);
(RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
@@ -319,12 +322,12 @@ public class VfcManager {
* @return
* @since ONAP Amsterdam Release
*/
- public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) {
+ public RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId) throws ApplicationException{
ValidateUtil.assertObjectNotNull(jobId);
// Step 1: query the current resource operation status
ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(nsOperationKey.getServiceId(),
- nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateId());
+ nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
// Step 2: start query
LOGGER.info("query ns status -> begin");
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
index 652de97f5f..a160b82e8a 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.constant;
/**
@@ -30,12 +31,6 @@ package org.openecomp.mso.adapters.vfc.constant;
*/
public class DriverExceptionID {
- public static final String INVALID_PARAM = "Invalid parameter";
-
- public static final String INTERNAL_ERROR = "Internal error";
-
- public static final String FAILED_TO_SVCTMPL_CATALOGUE = "Failed to get service template from catalogue";
-
public static final String INVALID_RESPONSE_FROM_INSTANTIATE_OPERATION =
"Invalid response from instantiate operation";
@@ -45,8 +40,6 @@ public class DriverExceptionID {
public static final String FAIL_TO_CREATE_NS = "Fail to create ns";
- public static final String INVALID_RESPONSEE_FROM_DELETE_OPERATION = "Invalid response from delete operation";
-
public static final String INVALID_RESPONSE_FROM_TERMINATE_OPERATION = "Invalid response from terminate operation";
public static final String FAIL_TO_DELETE_NS = "Fail to delete ns";
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java
index 6a78d2e73e..61966d07f2 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/exceptions/ApplicationException.java
@@ -17,19 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.exceptions;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response;;
-public class ApplicationException extends WebApplicationException {
+public class ApplicationException extends Exception {
/**
* Serial number.
*/
private static final long serialVersionUID = 1L;
+ private int errorCode;
+
+ private String errorMsg;
+
/**
* Constructor<br/>
* <p>
@@ -37,9 +40,37 @@ public class ApplicationException extends WebApplicationException {
*
* @param errorCode error status
* @param errorDetail error detail
- * @since ONAP Amsterdam Release 2017-9-6
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ public ApplicationException(int errorCode, String errorMsg) {
+ this.errorCode = errorCode;
+ this.errorMsg = errorMsg;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+ /**
+ * build error Response
+ * <br>
+ *
+ * @return
+ * @since ONAP Amsterdam Release
*/
- public ApplicationException(int errorCode, Object errorDetail) {
- super(Response.status(errorCode).entity(errorDetail).type(MediaType.APPLICATION_JSON).build());
+ public Response buildErrorResponse() {
+ return Response.status(errorCode).entity(errorMsg).build();
}
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
index ca1807ce62..f88a11dee8 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
@@ -30,38 +30,44 @@ public class NSResourceInputParameter {
private NsOperationKey nsOperationKey;
- private String subServiceName;
+ private String nsServiceName;
- private String subServiceDesc;
+ private String nsServiceDescription;
private NsParameters nsParameters;
+
+
+
/**
- * @return Returns the subServiceName.
+ * @return Returns the nsServiceName.
*/
- public String getSubServiceName() {
- return subServiceName;
+ public String getNsServiceName() {
+ return nsServiceName;
}
+
/**
- * @param subServiceName The subServiceName to set.
+ * @param nsServiceName The nsServiceName to set.
*/
- public void setSubServiceName(String subServiceName) {
- this.subServiceName = subServiceName;
+ public void setNsServiceName(String nsServiceName) {
+ this.nsServiceName = nsServiceName;
}
+
/**
- * @return Returns the subServiceDesc.
+ * @return Returns the nsServiceDescription.
*/
- public String getSubServiceDesc() {
- return subServiceDesc;
+ public String getNsServiceDescription() {
+ return nsServiceDescription;
}
+
/**
- * @param subServiceDesc The subServiceDesc to set.
+ * @param nsServiceDescription The nsServiceDescription to set.
*/
- public void setSubServiceDesc(String subServiceDesc) {
- this.subServiceDesc = subServiceDesc;
+ public void setNsServiceDescription(String nsServiceDescription) {
+ this.nsServiceDescription = nsServiceDescription;
}
/**
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java
index 884c3d2468..d6cfbde906 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsOperationKey.java
@@ -43,7 +43,7 @@ public class NsOperationKey {
/**
* the NS template uuid
*/
- private String nodeTemplateId;
+ private String nodeTemplateUUID;
/**
*
@@ -89,26 +89,20 @@ public class NsOperationKey {
this.operationId = operationId;
}
+
/**
- *
- * <br>
- *
- * @return
- * @since ONAP Amsterdam Release
+ * @return Returns the nodeTemplateUUID.
*/
- public String getNodeTemplateId() {
- return nodeTemplateId;
+ public String getNodeTemplateUUID() {
+ return nodeTemplateUUID;
}
+
/**
- *
- * <br>
- *
- * @param nodeTemplateId
- * @since ONAP Amsterdam Release
+ * @param nodeTemplateUUID The nodeTemplateUUID to set.
*/
- public void setNodeTemplateId(String nodeTemplateId) {
- this.nodeTemplateId = nodeTemplateId;
+ public void setNodeTemplateUUID(String nodeTemplateUUID) {
+ this.nodeTemplateUUID = nodeTemplateUUID;
}
-
+
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java
index 34beb02c13..a9546d5c4c 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/JsonUtil.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.util;
import java.io.IOException;
@@ -29,7 +30,6 @@ import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
-
/**
* Interface for json analyzing.<br/>
* <p>
@@ -43,7 +43,7 @@ public class JsonUtil {
/**
* Log service
*/
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
/**
* Mapper.
@@ -75,11 +75,12 @@ public class JsonUtil {
* @return model object
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static <T> T unMarshal(String jsonstr, Class<T> type) {
+ public static <T> T unMarshal(String jsonstr, Class<T> type) throws ApplicationException {
try {
return MAPPER.readValue(jsonstr, type);
} catch(IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "","", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e);
+ LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+ "fail to unMarshal json", e);
throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
}
}
@@ -92,11 +93,12 @@ public class JsonUtil {
* @return model object
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static <T> T unMarshal(String jsonstr, TypeReference<T> type) {
+ public static <T> T unMarshal(String jsonstr, TypeReference<T> type) throws ApplicationException {
try {
return MAPPER.readValue(jsonstr, type);
} catch(IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "","", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e);
+ LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+ "fail to unMarshal json", e);
throw new ApplicationException(HttpCode.BAD_REQUEST, "fail to unMarshal json");
}
}
@@ -108,11 +110,12 @@ public class JsonUtil {
* @return json string
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static String marshal(Object srcObj) {
+ public static String marshal(Object srcObj) throws ApplicationException {
try {
return MAPPER.writeValueAsString(srcObj);
} catch(IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "","", MsoLogger.ErrorCode.BusinessProcesssError, "fail to marshal json", e);
+ LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+ "fail to marshal json", e);
throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!");
}
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java
index 37228c805c..a6fa2d29e2 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/util/ValidateUtil.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.mso.adapters.vfc.util;
import org.openecomp.mso.adapters.vfc.constant.HttpCode;
@@ -49,7 +50,7 @@ public class ValidateUtil {
* @param name of parameter
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static void assertStringNotNull(String paramValue, String paramName) {
+ public static void assertStringNotNull(String paramValue, String paramName) throws ApplicationException {
if(null != paramValue && !paramValue.isEmpty()) {
return;
}
@@ -64,7 +65,7 @@ public class ValidateUtil {
* @param object data object
* @since ONAP Amsterdam Release 2017-9-6
*/
- public static void assertObjectNotNull(Object object) {
+ public static void assertObjectNotNull(Object object) throws ApplicationException {
if(null == object) {
LOGGER.error("Object is null.");
throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null.");
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
index 46ab134bce..4c316f3196 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
@@ -17,17 +17,29 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.vfc;
+package org.openecomp.mso.adapters.vfc;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
+import org.openecomp.mso.adapters.vfc.constant.CommonConstant;
+import org.openecomp.mso.adapters.vfc.constant.HttpCode;
+import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
import org.openecomp.mso.adapters.vfc.util.RestfulUtil;
import org.openecomp.mso.adapters.vfc.util.ValidateUtil;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+import org.openecomp.mso.requestsdb.ResourceOperationStatus;
+import mockit.Mock;
import mockit.MockUp;
/**
@@ -37,89 +49,150 @@ import mockit.MockUp;
* </p>
*
* @author
- * @version ONAP Amsterdam Release 2017-08-31
+ * @version ONAP Amsterdam Release 2017-08-31
*/
public class VfcAdapterTest {
- @Mock
- private static CatalogDatabase db;
+ private VfcAdapterRest vfcAdapter = new VfcAdapterRest();
/**
* File path
*/
private static final String FILE_PATH = "src/test/resources/json/";
- @Test
- public void createTest () {
-// // get request
-// mockGetRequestBody(FILE_PATH + "createNfvoNsReq.json");
-// // get service template
-// ServiceTemplate svcTmpl = new ServiceTemplate();
-// svcTmpl.setId("id");
-// svcTmpl.setServiceTemplateId("svcTmplId");
-// new MockUp<CatalogProxyImpl>() {
-// @Mock
-// public ServiceTemplate getSvcTmplByNodeType(String nodeType, String domainHost){
-// return svcTmpl;
-// }
-// };
-// // get response
-// RestfulResponse restRsp = new RestfulResponse();
-// restRsp.setStatus(HttpStatus.SC_OK);
-// restRsp.setResponseJson(getJsonString(FILE_PATH + "createNfvoNsRsp.json"));
-// mockGetRestfulRsp(restRsp);
-// // insert data
-// new MockUp<ServiceSegmentDaoImpl>() {
-// @Mock
-// public void insertSegment(ServiceSegmentModel serviceSegment) {
-// // do nothing
-// }
-// @Mock
-// public void insertSegmentOper(ServiceSegmentOperation svcSegmentOper) {
-// // do nothing
-// }
-// };
-// Response rsp = impl.createNfvoNs(servletReq);
-// JSONObject obj = JSONObject.fromObject(rsp.getEntity());
-// Assert.assertEquals(null, "1", obj.getString("nsInstanceId"));
+ /**
+ * Mock the request body form a file
+ * <br>
+ *
+ * @param fileName
+ * @since ONAP Amsterdam Release
+ */
+ private void mockRestfulUtil(String fileName) {
+ new MockUp<RestfulUtil>() {
+
+ /**
+ * mock get request body
+ * <br>
+ *
+ * @param request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public String getRequestBody(HttpServletRequest request) {
+ return getJsonString(fileName);
+ }
+
+ /**
+ * mock get send method
+ * <br>
+ *
+ * @param url
+ * @param methodType
+ * @param content
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public RestfulResponse send(String url, String methodType, String content) {
+ if(url.contains(CommonConstant.NFVO_CREATE_URL) && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("createNsRsp.json");
+ } else {
+ return null;
+ }
+ }
+ };
+ }
+
+ /**
+ * Mock the request body form a file
+ * <br>
+ *
+ * @param fileName
+ * @since ONAP Amsterdam Release
+ */
+ private void mockRequestDatabase() {
+ new MockUp<RequestsDatabase>() {
+
+ /**
+ * mock get resource operation status
+ * <br>
+ *
+ * @param request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId,
+ String resourceTemplateUUID) {
+ ResourceOperationStatus resStatus = new ResourceOperationStatus();
+ resStatus.setServiceId("111");
+ resStatus.setOperationId("111");
+ return resStatus;
+ }
+
+ /**
+ * Mock update Res Oper Status
+ * <br>
+ *
+ * @param operStatus
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public void updateResOperStatus(ResourceOperationStatus operStatus) {
+
+ }
+ };
+ }
+
+ /**
+ * Before executing UT, start mock requst database
+ * <br>
+ *
+ * @since ONAP Amsterdam Release
+ */
+ @Before
+ public void start() {
+ mockRequestDatabase();
+ }
+
+ /**
+ * After executing UT, close session<br/>
+ *
+ * @since ONAP Amsterdam Release
+ */
+ @After
+ public void stop() {
+
}
@Test
- public void deleteTest () {
-
+ public void createTest() {
+ // get request
+ mockRestfulUtil(FILE_PATH + "createNsReq.json");
+ vfcAdapter.createNfvoNs(null);
}
@Test
- public void instantiateTest () {
+ public void deleteTest() {
}
@Test
- public void terminateTest () {
-
+ public void instantiateTest() {
+
}
@Test
- public void queryJobTest () {
+ public void terminateTest() {
}
-
- /**
- * Mock to get request body.<br/>
- *
- * @param file json file path.
- * @since ONAP Amsterdam Release 2017-9-6
- */
- private void mockGetRequestBody(final String file) {
- new MockUp<RestfulUtil>() {
-// @Mock
-// public String getRequestBody(HttpServletRequest request) {
-// return getJsonString(file);
-// }
- };
+ @Test
+ public void queryJobTest() {
+
}
-
+
/**
* Get json string from file.<br/>
*
@@ -128,19 +201,37 @@ public class VfcAdapterTest {
* @throws IOException when fail to read
* @since ONAP Amsterdam Release 2017-9-6
*/
+ @SuppressWarnings("deprecation")
private String getJsonString(final String file) {
if(ValidateUtil.isStrEmpty(file)) {
return "";
}
String json = null;
-// try {
-// FileInputStream fileStream = new FileInputStream(new File(file));
-// json = IOUtils.toString(fileStream);
-// } catch(Exception e) {
-// Assert.fail(e.getMessage());
-// }
-
+ try {
+ FileInputStream fileStream = new FileInputStream(new File(file));
+ json = IOUtils.toString(fileStream);
+ } catch(Exception e) {
+ Assert.fail(e.getMessage());
+ }
return json;
}
+
+ /**
+ * get the response from file
+ * <br>
+ *
+ * @param fileName
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ private RestfulResponse getResponse(String fileName) {
+ RestfulResponse responseSuccess = new RestfulResponse();
+ responseSuccess.setStatus(HttpCode.RESPOND_OK);
+ if(null != fileName) {
+ String jsonStr = getJsonString(FILE_PATH + fileName);
+ responseSuccess.setResponseContent(jsonStr);
+ }
+ return responseSuccess;
+ }
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy
new file mode 100644
index 0000000000..3302210416
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericE2EServiceInstance.groovy
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.infrastructure.scripts;
+
+import static org.apache.commons.lang3.StringUtils.*;
+import groovy.xml.XmlUtil
+import groovy.json.*
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.scripts.VidUtils
+import org.openecomp.mso.bpmn.core.WorkflowException
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.rest.APIResponse
+
+import java.util.UUID;
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.runtime.Execution
+import org.apache.commons.lang3.*
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.util.UriUtils
+
+/**
+ * This groovy class supports the <class>CreateGenericE2EServiceInstance.bpmn</class> process.
+ * flow for E2E ServiceInstance Create
+ */
+public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcessor {
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ VidUtils vidUtils = new VidUtils()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * Deal with the parameters
+ * generate the service instance id
+ * generate the operation id
+ */
+ public void preProcessRequest (Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ String msg = ""
+ utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)
+ try {
+
+ String siRequest = execution.getVariable("bpmnRequest")
+ utils.logAudit(siRequest)
+
+ String requestId = execution.getVariable("mso-request-id")
+ execution.setVariable("msoRequestId", requestId)
+ utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled)
+
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ if (isBlank(serviceInstanceId)) {
+ serviceInstanceId = UUID.randomUUID().toString()
+ }
+ utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled)
+ serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
+ execution.setVariable("serviceInstanceId", serviceInstanceId)
+
+ String operationId = execution.getVariable("operationId")
+ if (isBlank(operationId)) {
+ operationId = UUID.randomUUID().toString()
+ }
+ utils.log("DEBUG", "Generated new Service Instance Operation:" + operationId, isDebugEnabled)
+ serviceInstanceId = UriUtils.encode(operationId,"UTF-8")
+ execution.setVariable("operationId", operationId)
+ //subscriberInfo, TBD , there is no globalSubscriberId in R1 for E2E Service.
+ //requestInfo TBD , there is no requestDetails for R1 E2E service
+
+ //TBD need to insert operationInfo to RequestDb
+
+ //set service Instance Name
+ execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "service.name"))
+ execution.setVariable("serviceDescription", jsonUtil.getJsonValue(siRequest, "service.description"))
+ execution.setVariable("templateId", jsonUtil.getJsonValue(siRequest, "service.templateId"))
+
+ //serviceParamters
+ String serviceParamters = jsonUtil.getJsonValue(siRequest, "service.parameters")
+ if (isBlank(serviceParamters)) {
+ msg = "Input service paramters is null"
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else
+ {
+ execution.setVariable("serviceParamters", serviceParamters)
+ }
+
+ utils.log("DEBUG", "service parameters:" + serviceParamters, isDebugEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
+ }
+
+ /**
+ * send the sync response
+ * the response incloudes the instance id and the operation id
+ */
+ public void sendSyncResponse(Execution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+
+ try {
+ String requestId = execution.getVariable("msoRequestId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ // RESTResponse for API Handler (APIH) Reply Task
+ String createServiceRestResponse = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim()
+ utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestResponse, isDebugEnabled)
+ sendWorkflowResponse(execution, 202, createServiceRestResponse)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
+ }
+
+ public void preCreateRequest(Execution execution) {
+ }
+
+ public void postConfigRequest(Execution execution) {
+ }
+
+ public void preVFCRequest(Execution execution) {
+ }
+
+ public void preAdaptorDataRequest(Execution execution) {
+ }
+
+ public void preSDNCRequest(Execution execution) {
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index 4490d78648..f9150fabf0 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -240,6 +240,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java
new file mode 100644
index 0000000000..ee789a60ca
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java
@@ -0,0 +1,491 @@
+package org.openecomp.mso.apihandlerinfra;
+
+
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.junit.Test;
+
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class ServiceInstanceTest {
+
+ /*** Create Service Instance Test Cases ***/
+
+ @Test
+ public void createServiceInstanceInvalidModelInfo(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v5");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid model-info is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNormalNullDBFatch(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
+ return Collections.EMPTY_LIST;
+ }
+ };
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Recipe could not be retrieved from catalog DB null") != -1);
+ }
+
+
+ @Test
+ public void createServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v5");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullInstanceName(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid instanceName is specified") != -1);
+ }
+
+
+ @Test
+ public void createServiceInstanceNullModelInfo(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid model-info is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceInvalidModelInvariantId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"1234\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullModelVersion(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ }
+
+
+ @Test
+ public void createServiceInstanceNullModelType(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceInvalidModelType(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"testmodel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Mapping of request to JSON object failed.") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullModelName(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid modelName is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceInvalidVersionForAutoBuildVfModules(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": true},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. AutoBuildVfModule is not valid in the v2 version") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullRequestParameter(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid subscriptionServiceType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceNullSubscriptionType(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\"},\"requestParameters\": { \"autoBuildVfModules\": false},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respBody = resp.getEntity().toString();
+ assertTrue(respBody.indexOf("Error parsing request. No valid subscriptionServiceType is specified") != -1);
+ }
+
+ @Test
+ public void createServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.createServiceInstance(requestJson, "v2");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ /*** Activate Service Instance Test Cases ***/
+
+ @Test
+ public void activateServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ @Test
+ public void activateServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId in relatedInstance is specified") != -1);
+ }
+
+ @Test
+ public void activateServiceInstanceInvalidServiceInstanceId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified") != -1);
+ }
+
+ @Test
+ public void activateServiceInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.activateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Deactivate Service Instance Test Cases ***/
+
+ @Test
+ public void deactivateServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ @Test
+ public void deactivateServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId in relatedInstance is specified") != -1);
+ }
+
+ @Test
+ public void deactivateServiceInstanceInvalidServiceInstanceId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid serviceInstanceId matching the serviceInstanceId in request URI is specified") != -1);
+ }
+
+ @Test
+ public void deactivateServiceInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deactivateServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Delete Service Instance Test Cases ***/
+
+ @Test
+ public void deleteServiceInstanceAnbormalInvalidJson(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"name\":\"test\"}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Mapping of request to JSON object failed") != -1);
+ }
+
+ @Test
+ public void deleteServiceInstanceInvalidModelVersionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ }
+
+ @Test
+ public void deleteServiceInstanceInvalidServiceInstanceId(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d37\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\"}}}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid modelVersionId is specified") != -1);
+ }
+
+ @Test
+ public void deleteServiceInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.deleteServiceInstance(requestJson, "v5","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Create Vnf Instance Test Cases ***/
+
+ @Test
+ public void createVNFInstanceTestInvalidCloudConfiguration(){
+ ServiceInstances instance = new ServiceInstances();
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid cloudConfiguration is specified") != -1);
+ }
+
+ @Test
+ public void createVNFInstanceTestInvalidIcpCloudRegionId(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid lcpCloudRegionId is specified") != -1);
+ }
+
+ @Test
+ public void createVNFInstanceTestInvalidTenantId(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("Error parsing request. No valid tenantId is specified") != -1);
+ }
+
+ @Test
+ public void createVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.createVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Replace Vnf Instance Test Cases ***/
+ @Test
+ public void replaceVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.replaceVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Update Vnf Instance Test Cases ***/
+
+ @Test
+ public void updateVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.updateVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+
+ /*** Update Vnf Instance Test Cases ***/
+
+ @Test
+ public void deleteVNFInstanceTestNormal(){
+ ServiceInstances instance = new ServiceInstances();
+ String s = "\"cloudConfiguration\":{}";
+ String requestJson = "{\"serviceInstanceId\":\"1882939\","
+ +"\"vnfInstanceId\":\"1882938\","
+ +"\"networkInstanceId\":\"1882937\","
+ +"\"volumeGroupInstanceId\":\"1882935\","
+ +"\"vfModuleInstanceId\":\"1882934\","
+ + "\"requestDetails\": {\"cloudConfiguration\":{\"lcpCloudRegionId\":\"2993841\",\"tenantId\":\"2910032\"}, \"relatedInstanceList\" :[{\"relatedInstance\":{\"instanceName\":\"testInstance\",\"instanceId\":\"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"4839499\"}}}],\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"zz9999\",\"instanceName\": \"testService\"},\"requestParameters\": { \"autoBuildVfModules\": false,\"subscriptionServiceType\": \"test\"},\"modelInfo\":{\"modelInvariantId\": \"557ea944-c83e-43cf-9ed7-3a354abd6d34\",\"modelVersion\":\"v2\",\"modelType\":\"service\",\"modelName\":\"serviceModel\",\"modelVersionId\":\"288393\",\"modelCustomizationId\":\"389823213\"}}}";
+ Response resp = instance.deleteVnfInstance(requestJson, "v3","557ea944-c83e-43cf-9ed7-3a354abd6d34","557ea944-c83e-43cf-9ed7-3a354abd6d93");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ }
+}