summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java125
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java47
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java49
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java120
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java135
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java2711
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json50
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json54
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json53
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json34
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json71
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml70
35 files changed, 2361 insertions, 1584 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
index 3eee14e3bf..5b08cc1b17 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
@@ -42,5 +42,6 @@ public enum Action implements Actions{
unassignInstance,
compareModel,
scaleInstance,
- deactivateAndCloudDelete
+ deactivateAndCloudDelete,
+ scaleOut
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index ee50d920fe..e8a6beb278 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -56,10 +56,8 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
-import org.onap.so.db.catalog.data.repository.ServiceRecipeRepository;
-import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.OperationStatus;
-import org.onap.so.db.request.data.repository.OperationStatusRepository;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoAlarmLogger;
import org.onap.so.logger.MsoLogger;
@@ -84,14 +82,12 @@ import com.wordnik.swagger.annotations.ApiOperation;
public class E2EServiceInstances {
private HashMap<String, String> instanceIdMap = new HashMap<>();
- private static MsoLogger msoLogger = MsoLogger
+ private static final MsoLogger msoLogger = MsoLogger
.getMsoLogger(MsoLogger.Catalog.APIH, E2EServiceInstances.class);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
- public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+ private static final MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+ private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
- public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
- public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB";
- public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine";
+ private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
@Autowired
private MsoRequest msoRequest;
@@ -100,13 +96,10 @@ public class E2EServiceInstances {
private RequestClientFactory requestClientFactory;
@Autowired
- private OperationStatusRepository osRepo;
+ private RequestsDbClient requestsDbClient;
@Autowired
- private ServiceRepository serviceRepo;
-
- @Autowired
- private ServiceRecipeRepository sRecipeRepo;
+ private CatalogDbClient catalogDbClient;
@Autowired
private ResponseBuilder builder;
@@ -224,7 +217,7 @@ public class E2EServiceInstances {
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
- CompareModelsRequest e2eCompareModelReq = null;
+ CompareModelsRequest e2eCompareModelReq;
ObjectMapper mapper = new ObjectMapper();
try {
@@ -256,8 +249,8 @@ public class E2EServiceInstances {
String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance";
int recipeTimeout = 180;
- RequestClient requestClient = null;
- HttpResponse response = null;
+ RequestClient requestClient;
+ HttpResponse response;
long subStartTime = System.currentTimeMillis();
@@ -327,12 +320,11 @@ public class E2EServiceInstances {
long startTime = System.currentTimeMillis();
- OperationStatus operationStatus = null;
+ OperationStatus operationStatus;
try {
- operationStatus = osRepo.findOneByServiceIdAndOperationId(serviceId,
+ operationStatus = requestsDbClient.getOneByServiceIdAndOperationId(serviceId,
operationId);
-
} catch (Exception e) {
msoLogger
.error(MessageEnum.APIH_DB_ACCESS_EXC,
@@ -353,7 +345,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with Request DB");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
@@ -371,7 +363,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.DataNotFound,
"Null response from RequestDB when searching by serviceId");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) resp.getEntity());
+ + resp.getEntity());
return resp;
}
@@ -387,7 +379,7 @@ public class E2EServiceInstances {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
- E2EServiceInstanceDeleteRequest e2eDelReq = null;
+ E2EServiceInstanceDeleteRequest e2eDelReq;
ObjectMapper mapper = new ObjectMapper();
try {
@@ -410,11 +402,11 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.SchemaError,
"Mapping of request to JSON object failed");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
- RecipeLookupResult recipeLookupResult = null;
+ RecipeLookupResult recipeLookupResult;
try {
//TODO Get the service template model version uuid from AAI.
recipeLookupResult = getServiceInstanceOrchestrationURI(null, action);
@@ -436,7 +428,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
if (recipeLookupResult == null) {
@@ -454,12 +446,12 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
- RequestClient requestClient = null;
- HttpResponse response = null;
+ RequestClient requestClient;
+ HttpResponse response;
long subStartTime = System.currentTimeMillis();
try {
@@ -514,7 +506,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.CommunicationError,
"Exception while communicate with BPMN engine");
msoLogger.debug("End of the transaction, the final response is: "
- + (String) resp.getEntity());
+ + resp.getEntity());
return resp;
}
@@ -530,7 +522,7 @@ public class E2EServiceInstances {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
@@ -548,7 +540,7 @@ public class E2EServiceInstances {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
- E2EServiceInstanceRequest e2eSir = null;
+ E2EServiceInstanceRequest e2eSir;
String serviceId = instanceIdMap.get("serviceId");
ObjectMapper mapper = new ObjectMapper();
@@ -565,7 +557,7 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
"Mapping of request to JSON object failed");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -585,11 +577,11 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
"Validation of the input request failed");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
- RecipeLookupResult recipeLookupResult = null;
+ RecipeLookupResult recipeLookupResult;
try {
recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action);
} catch (Exception e) {
@@ -603,7 +595,7 @@ public class E2EServiceInstances {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -617,15 +609,15 @@ public class E2EServiceInstances {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
String serviceInstanceType = e2eSir.getService().getServiceType();
- RequestClient requestClient = null;
- HttpResponse response = null;
+ RequestClient requestClient;
+ HttpResponse response;
long subStartTime = System.currentTimeMillis();
String sirRequestJson = convertToString(sir);
@@ -665,7 +657,7 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
"Exception while communicate with BPMN engine");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) getBPMNResp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity());
return getBPMNResp;
}
@@ -677,7 +669,7 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) getBPMNResp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity());
return getBPMNResp;
}
@@ -694,7 +686,7 @@ public class E2EServiceInstances {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
- E2EServiceInstanceRequest e2eSir = null;
+ E2EServiceInstanceRequest e2eSir;
MsoRequest msoRequest = new MsoRequest();
ObjectMapper mapper = new ObjectMapper();
@@ -711,7 +703,7 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
"Mapping of request to JSON object failed");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -731,11 +723,11 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
"Validation of the input request failed");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
- RecipeLookupResult recipeLookupResult = null;
+ RecipeLookupResult recipeLookupResult;
try {
recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action);
} catch (Exception e) {
@@ -749,7 +741,7 @@ public class E2EServiceInstances {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
@@ -762,15 +754,15 @@ public class E2EServiceInstances {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
String serviceInstanceType = e2eSir.getService().getServiceType();
String serviceId = "";
- RequestClient requestClient = null;
- HttpResponse response = null;
+ RequestClient requestClient;
+ HttpResponse response;
long subStartTime = System.currentTimeMillis();
String sirRequestJson = convertToString(sir);
@@ -809,7 +801,7 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
"Exception while communicate with BPMN engine");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
@@ -820,7 +812,7 @@ public class E2EServiceInstances {
MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
@@ -837,7 +829,7 @@ public class E2EServiceInstances {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
- E2EServiceInstanceScaleRequest e2eScaleReq = null;
+ E2EServiceInstanceScaleRequest e2eScaleReq;
ObjectMapper mapper = new ObjectMapper();
try {
@@ -860,11 +852,11 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.SchemaError,
"Mapping of request to JSON object failed");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
- RecipeLookupResult recipeLookupResult = null;
+ RecipeLookupResult recipeLookupResult;
try {
//TODO Get the service template model version uuid from AAI.
recipeLookupResult = getServiceInstanceOrchestrationURI(null, action);
@@ -886,7 +878,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
if (recipeLookupResult == null) {
@@ -903,12 +895,12 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) response.getEntity());
+ + response.getEntity());
return response;
}
- RequestClient requestClient = null;
- HttpResponse response = null;
+ RequestClient requestClient;
+ HttpResponse response;
long subStartTime = System.currentTimeMillis();
try {
@@ -963,7 +955,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.CommunicationError,
"Exception while communicate with BPMN engine");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) resp.getEntity());
+ + resp.getEntity());
return resp;
}
@@ -979,7 +971,7 @@ public class E2EServiceInstances {
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
@@ -1028,7 +1020,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.InternalError,
"Response from BPMN engine is failed");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) resp.getEntity());
+ + resp.getEntity());
return resp;
} else {
Response resp = msoRequest
@@ -1047,7 +1039,7 @@ public class E2EServiceInstances {
MsoLogger.ResponseCode.InternalError,
"Response from BPEL engine is empty");
msoLogger.debug(END_OF_THE_TRANSACTION
- + (String) resp.getEntity());
+ + resp.getEntity());
return resp;
}
}
@@ -1056,7 +1048,6 @@ public class E2EServiceInstances {
/**
* Getting recipes from catalogDb
*
- * @param db the catalog db
* @param serviceModelUUID the service model version uuid
* @param action the action for the service
* @return the service recipe result
@@ -1079,7 +1070,6 @@ public class E2EServiceInstances {
/**
* Getting recipes from catalogDb
* If Service recipe is not set, use default recipe, if set , use special recipe.
- * @param db the catalog db
* @param serviceModelUUID the service version uuid
* @param action the action of the service.
* @return the service recipe result.
@@ -1088,13 +1078,12 @@ public class E2EServiceInstances {
String defaultServiceModelName = "UUI_DEFAULT";
- Service defaultServiceRecord = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
- ServiceRecipe defaultRecipe = sRecipeRepo.findFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name());
+ Service defaultServiceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
//set recipe as default generic recipe
- ServiceRecipe recipe = defaultRecipe;
+ ServiceRecipe recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name());
//check the service special recipe
if(null != serviceModelUUID && ! serviceModelUUID.isEmpty()){
- ServiceRecipe serviceSpecialRecipe = sRecipeRepo.findFirstByServiceModelUUIDAndAction(
+ ServiceRecipe serviceSpecialRecipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(
serviceModelUUID, action.name());
if(null != serviceSpecialRecipe){
//set service special recipe.
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index a93feb6cd9..66afcf3738 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -44,6 +44,7 @@ import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
+import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation;
import org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation;
import org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation;
import org.onap.so.apihandlerinfra.validation.ModelInfoValidation;
@@ -95,7 +96,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class MsoRequest {
@Autowired
- private InfraActiveRequestsRepository iarRepo;
+ private RequestsDbClient requestsDbClient;
@Autowired
private ResponseBuilder builder;
@@ -178,6 +179,7 @@ public class MsoRequest {
rules.add(new PlatformLOBValidation());
rules.add(new ProjectOwningEntityValidation());
rules.add(new RelatedInstancesValidation());
+ rules.add(new ConfigurationParametersValidation());
}
if(reqVersion >= 7 && requestParameters != null && requestParameters.getUserParams() != null){
for(Map<String, Object> params : requestParameters.getUserParams()){
@@ -426,7 +428,7 @@ public class MsoRequest {
request.setRequestBody(requestJSON);
Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
request.setEndTime(endTimeStamp);
- iarRepo.save(request);
+ requestsDbClient.save(request);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB");
msoLogger.debug ("Exception: ", e);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 3a944473d9..014739d581 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -102,7 +102,7 @@ public class OrchestrationRequests {
requestDB = requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
} catch (Exception e) {
-
+ msoLogger.error(e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.AvailabilityError).build();
AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL, Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)).build();
@@ -156,12 +156,10 @@ public class OrchestrationRequests {
throw new ValidationException("At least one filter query param must be specified");
}
}catch(ValidationException ex){
+ msoLogger.error(ex);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.DataError).build();
-
-
ValidateException validateException = new ValidateException.Builder(ex.getMessage(),
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build();
-
throw validateException;
}
@@ -202,10 +200,8 @@ public class OrchestrationRequests {
ObjectMapper mapper = new ObjectMapper();
sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
} catch(IOException e){
-
+ msoLogger.error(e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
-
-
ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
@@ -215,6 +211,7 @@ public class OrchestrationRequests {
try{
msoRequest.parseOrchestration(sir);
} catch (Exception e) {
+ msoLogger.error(e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
@@ -301,7 +298,7 @@ public class OrchestrationRequests {
requestDetails = mapper.readValue(requestBody, RequestDetails.class);
}
} catch (IOException e) {
-
+ msoLogger.error(e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : ",
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
index 466de0aa0e..380ee2c6ad 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
@@ -22,6 +22,7 @@ package org.onap.so.apihandlerinfra;
import org.apache.http.HttpStatus;
import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -30,10 +31,6 @@ import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpRequest;
-import org.springframework.http.client.ClientHttpRequestExecution;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
-import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
@@ -41,10 +38,9 @@ import org.springframework.web.client.RestTemplate;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
-import uk.co.blackpepper.bowman.RestTemplateConfigurer;
import javax.annotation.PostConstruct;
-import java.io.IOException;
+import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
@@ -53,7 +49,11 @@ import java.util.Map;
@Component("RequestDbClient")
public class RequestsDbClient {
+ private static final String SERVICE_ID = "SERVICE_ID";
+ private static final String OPERATION_ID = "OPERATION_ID";
+
private Client<InfraActiveRequests> infraActiveRequestClient;
+ private Client<OperationStatus> operationStatusClient;
@Value("${mso.adapters.requestDb.endpoint}")
private String endpoint;
@@ -62,12 +62,15 @@ public class RequestsDbClient {
private String msoAdaptersAuth;
private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/";
+ private static final String OPERATION_STATUS_REPOSITORY_SEARCH = "/operationStatusRepository/search";
private String checkVnfIdStatus = "/infraActiveRequests/checkVnfIdStatus/";
private String infraActiveRequestURI = "/infraActiveRequests/";
private String checkInstanceNameDuplicate = "/infraActiveRequests/checkInstanceNameDuplicate";
+
+ private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId";
private String cloudOrchestrationFiltersFromInfraActive = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive";
@@ -83,27 +86,18 @@ public class RequestsDbClient {
checkVnfIdStatus = endpoint + checkVnfIdStatus;
checkInstanceNameDuplicate = endpoint + checkInstanceNameDuplicate;
cloudOrchestrationFiltersFromInfraActive = endpoint + cloudOrchestrationFiltersFromInfraActive;
+ findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_REPOSITORY_SEARCH + findOneByServiceIdAndOperationIdURI;
headers = new HttpHeaders();
headers.set("Authorization", msoAdaptersAuth);
}
public RequestsDbClient() {
- ClientFactory clientFactory = Configuration.builder().setRestTemplateConfigurer(new RestTemplateConfigurer() {
-
- public void configure(RestTemplate restTemplate) {
-
- restTemplate.getInterceptors().add(new ClientHttpRequestInterceptor() {
-
- public ClientHttpResponse intercept(HttpRequest request, byte[] body,
- ClientHttpRequestExecution execution) throws IOException {
-
- request.getHeaders().add("Authorization", msoAdaptersAuth);
- return execution.execute(request, body);
- }
- });
- }
- }).build().buildClientFactory();
+ ClientFactory clientFactory = Configuration.builder().setRestTemplateConfigurer(restTemplate -> restTemplate.getInterceptors().add((request, body, execution) -> {
+ request.getHeaders().add("Authorization", msoAdaptersAuth);
+ return execution.execute(request, body);
+ })).build().buildClientFactory();
infraActiveRequestClient = clientFactory.create(InfraActiveRequests.class);
+ operationStatusClient = clientFactory.create(OperationStatus.class);
}
public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap){
@@ -145,6 +139,13 @@ public class RequestsDbClient {
}
}
+
+ public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId){
+ return this.getSingleOperationStatus(UriBuilder.fromUri(findOneByServiceIdAndOperationIdURI)
+ .queryParam(SERVICE_ID,serviceId)
+ .queryParam(OPERATION_ID,operationId)
+ .build());
+ }
public void save(InfraActiveRequests infraActiveRequests) {
URI uri = getUri(infraActiveRequestURI);
@@ -159,6 +160,10 @@ public class RequestsDbClient {
public void updateInfraActiveRequests(InfraActiveRequests request) {
infraActiveRequestClient.put(request);
}
+
+ public OperationStatus getSingleOperationStatus(URI uri){
+ return operationStatusClient.get(uri);
+ }
protected URI getUri(String uri) {
return URI.create(uri);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index e259839d6e..ced69df55c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -525,6 +525,21 @@ public class ServiceInstances {
Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, getRequestUri(requestContext));
return response;
}
+
+ @POST
+ @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="VF Auto Scale Out",response=Response.class)
+ @Transactional
+ public Response scaleOutVfModule(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
@POST
@@ -845,8 +860,20 @@ public class ServiceInstances {
throw clientException;
}
- ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
- int bpelStatus = respHandler.getStatus ();
+ ResponseHandler respHandler = null;
+ int bpelStatus = 500;
+ try {
+ respHandler = new ResponseHandler (response, requestClient.getType ());
+ bpelStatus = respHandler.getStatus ();
+ } catch (ApiException e) {
+ msoLogger.error(e);
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ currentActiveReq.setRequestStatus(Status.FAILED.name());
+ currentActiveReq.setStatusMessage(validateException.getMessage());
+ throw validateException;
+ }
// BPEL accepted the request, the request is in progress
if (bpelStatus == HttpStatus.SC_ACCEPTED) {
@@ -858,7 +885,7 @@ public class ServiceInstances {
ObjectMapper mapper = new ObjectMapper();
jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
} catch (IOException e) {
- e.printStackTrace();
+ msoLogger.error(e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
index 4c7365b187..f366c7e74b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
@@ -53,7 +53,7 @@ public class CloudConfigurationValidation implements ValidationRule{
(action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){
throw new ValidationException ("cloudConfiguration");
}
- if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.deactivateAndCloudDelete){
+ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){
throw new ValidationException("cloudConfiguration");
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java
new file mode 100644
index 0000000000..edd1b1a10e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * 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.onap.so.apihandlerinfra.validation;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+
+public class ConfigurationParametersValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ ServiceInstancesRequest sir = info.getSir();
+ List<Map<String, String>> configParams = sir.getRequestDetails().getConfigurationParameters();
+ String requestScope = info.getRequestScope();
+ Actions action = info.getAction();
+
+ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && configParams.isEmpty()){
+ throw new ValidationException("configuration parameters");
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
index 8ab7fccdff..aa98d2abf2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
@@ -23,6 +23,7 @@ package org.onap.so.apihandlerinfra.validation;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.apihandlerinfra.TestApi;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.ModelType;
@@ -73,19 +74,22 @@ public class ModelInfoValidation implements ValidationRule{
(requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
throw new ValidationException ("modelInvariantId");
}
+ if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
+ throw new ValidationException("modelInvariantId");
+ }
if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
throw new ValidationException ("modelInvariantId format");
}
if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
- action == Action.addRelationships || action == Action.removeRelationships || (action == Action.deleteInstance && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
+ action == Action.addRelationships || action == Action.removeRelationships || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
throw new ValidationException ("modelName");
}
if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
(!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
- && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships))) {
+ && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) {
throw new ValidationException ("modelVersion");
}
@@ -95,6 +99,9 @@ public class ModelInfoValidation implements ValidationRule{
(requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
throw new ValidationException ("modelVersionId");
}
+ if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){
+ throw new ValidationException("modelVersionId");
+ }
if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
@@ -106,6 +113,9 @@ public class ModelInfoValidation implements ValidationRule{
&& (action == Action.updateInstance || action == Action.createInstance)){
throw new ValidationException ("modelCustomizationId");
}
+ if(empty(modelInfo.getModelCustomizationId()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)){
+ throw new ValidationException ("modelCustomizationId");
+ }
return info;
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
index 096b30939b..1f4fbc974a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
@@ -217,7 +217,8 @@ public class RelatedInstancesValidation implements ValidationRule{
}
else if ((( requestScope.equalsIgnoreCase(ModelType.vnf.name ()) || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())
|| requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (action == Action.createInstance || action == Action.enablePort || action == Action.disablePort)) ||
- (reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance) ||
+ (reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance ||
+ (requestScope.equalsIgnoreCase(ModelType.vfModule.name ()) && action == Action.scaleOut)) ||
(requestScope.equalsIgnoreCase(ModelType.service.name()) && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))){
msoLogger.debug ("related instance exception");
throw new ValidationException ("related instances");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml
index 3252146bfa..acc04061cf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application-local.yaml
@@ -17,6 +17,10 @@ camunda-nodehealthcheck-urn: /mso/nodehealthcheck
mso:
+ adapters:
+ requestDb:
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
+ endpoint: http://localhost:8081
logPath: logs
site-name: mtanj
catalog:
@@ -42,8 +46,6 @@ mso:
sdna:
url: http://localhost:8089/
password: 4112B789E942B161228F7D5AFC654C0F
- bpelURL: http://localhost:8080/
- bpelAuth: 786864AA53D0DCD881AED1154230C0C3058D58B9339D2EFB6193A0F0D82530E1
camundaURL: http://localhost:8089/
camundaAuth: F8E9452B55DDE4CCE77547B0E748105C54CF5EF1351B4E2CBAABF2981EFE776D
async:
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
index 2baa54fdec..a63b778a1f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java
@@ -20,10 +20,7 @@
package org.onap.so.apihandlerinfra;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@@ -33,11 +30,17 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.junit.Ignore;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.http.HttpStatus;
+import org.junit.Before;
import org.junit.Test;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.serviceinstancebeans.RequestError;
import org.onap.so.serviceinstancebeans.ServiceException;
import org.springframework.http.HttpEntity;
@@ -45,43 +48,65 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.http.Fault;
public class E2EServiceInstancesTest extends BaseTest {
-private ObjectMapper mapper = new ObjectMapper();
+private final ObjectMapper mapper = new ObjectMapper();
private final String e2eServInstancesUri = "/e2eServiceInstances/";
+
+ @Before
+ public void init() throws JsonProcessingException {
+ stubFor(post(urlPathEqualTo("/testOrchestrationUri"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(equalToJson("{\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"Error parsing request: No valid requestorId is specified\",\"progress\":100,\"startTime\":1533541051247,\"endTime\":1533541051247,\"source\":null,\"vnfId\":null,\"vnfName\":null,\"vnfType\":null,\"serviceType\":null,\"aicNodeClli\":null,\"tenantId\":null,\"provStatus\":null,\"vnfParams\":null,\"vnfOutputs\":null,\"requestBody\":\"{\\r\\n \\\"service\\\":{\\r\\n \\\"name\\\":\\\"so_test4\\\",\\r\\n \\\"description\\\":\\\"so_test2\\\",\\r\\n \\\"serviceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561519\\\",\\r\\n \\\"serviceUuid\\\":\\\"592f9437-a9c0-4303-b9f6-c445bb7e9814\\\",\\r\\n \\\"globalSubscriberId\\\":\\\"123457\\\",\\r\\n \\\"serviceType\\\":\\\"voLTE\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"resources\\\":[\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vIMS\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vBAS-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vMME-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vEPC\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"61c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"62c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-CSCF-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad1\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"underlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561513\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561514\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"overlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561517\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561518\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n }\\r\\n ],\\r\\n \\\"requestInputs\\\":{\\r\\n \\\"externalDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"m6000_mng_ip\\\":\\\"181.18.20.2\\\",\\r\\n \\\"externalCompanyFtpDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"externalPluginManageNetworkName\\\":\\\"plugin_net_2014\\\",\\r\\n \\\"externalManageNetworkName\\\":\\\"mng_net_2017\\\",\\r\\n \\\"sfc_data_network\\\":\\\"sfc_data_net_2016\\\",\\r\\n \\\"NatIpRange\\\":\\\"210.1.1.10-210.1.1.20\\\",\\r\\n \\\"location\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\",\\r\\n \\\"sdncontroller\\\":\\\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\\\"\\r\\n }\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n}\",\"responseBody\":null,\"lastModifiedBy\":\"APIH\",\"modifyTime\":null,\"requestType\":null,\"volumeGroupId\":null,\"volumeGroupName\":null,\"vfModuleId\":null,\"vfModuleName\":null,\"vfModuleModelName\":null,\"aaiServiceId\":null,\"aicCloudRegion\":null,\"callBackUrl\":null,\"correlator\":null,\"serviceInstanceId\":null,\"serviceInstanceName\":null,\"requestScope\":\"service\",\"requestAction\":\"createInstance\",\"networkId\":null,\"networkName\":null,\"networkType\":null,\"requestorId\":null,\"configurationId\":null,\"configurationName\":null,\"operationalEnvId\":null,\"operationalEnvName\":null,\"requestURI\":\"d167c9d0-1785-4e93-b319-996ebbcc3272\"}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_OK)));
+ Service defaultService = new Service();
+ defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
+ ServiceRecipe serviceRecipe = new ServiceRecipe();
+ serviceRecipe.setServiceModelUUID(defaultService.getModelUUID());
+ serviceRecipe.setAction(Action.scaleInstance.name());
+ serviceRecipe.setRecipeTimeout(180);
+ serviceRecipe.setOrchestrationUri("/testOrchestrationUri");
+
+ stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(serviceRecipe))
+ .withStatus(HttpStatus.SC_OK)));
+
+ }
public String inputStream(String JsonInput)throws IOException{
JsonInput = "src/test/resources/E2EServiceInstancesTest" + JsonInput;
- String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
- return input;
+ return new String(Files.readAllBytes(Paths.get(JsonInput)));
}
public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type",MediaType.APPLICATION_JSON);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
- HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
- ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
+ HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
+
+ return restTemplate.exchange(builder.toUriString(),
reqMethod, request, String.class);
-
- return response;
}
- //Currently returning a 500 response
- @Ignore
+
@Test
- public void createE2EServiceInstanceNoRequestInfo() throws JsonParseException, JsonMappingException, IOException{
- String uri = e2eServInstancesUri + "v5";
+ public void createE2EServiceInstanceNoRequestInfo() throws IOException{
+ String uri = e2eServInstancesUri + "v3";
ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
}
@Test
- public void updateE2EServiceInstanceJSONMappingError() throws JsonParseException, JsonMappingException, IOException{
+ public void updateE2EServiceInstanceJSONMappingError() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.PUT);
@@ -90,7 +115,7 @@ private ObjectMapper mapper = new ObjectMapper();
assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
}
@Test
- public void updateE2EServiceInstanceNoRequestorId() throws JsonParseException, JsonMappingException, IOException{
+ public void updateE2EServiceInstanceNoRequestorId() throws IOException{
RequestError expectedResponse = new RequestError();
ServiceException exception = new ServiceException();
exception.setMessageId("SVC0002");
@@ -105,7 +130,7 @@ private ObjectMapper mapper = new ObjectMapper();
assertThat(realResponse, sameBeanAs(expectedResponse));
}
@Test
- public void deleteE2EServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{
+ public void deleteE2EServiceInstance() throws IOException{
RequestError expectedResponse = new RequestError();
ServiceException exception = new ServiceException();
exception.setMessageId("SVC1000");
@@ -115,12 +140,10 @@ private ObjectMapper mapper = new ObjectMapper();
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
ResponseEntity<String> response = sendRequest(inputStream("/DeleteRequest.json"), uri, HttpMethod.DELETE);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
- assertThat(realResponse, sameBeanAs(expectedResponse));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
}
@Test
- public void deleteE2EServiceInstanceNotValid() throws JsonParseException, JsonMappingException, IOException{
+ public void deleteE2EServiceInstanceNotValid() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.DELETE);
@@ -129,14 +152,14 @@ private ObjectMapper mapper = new ObjectMapper();
assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
}
@Test
- public void getE2EServiceInstanceNullOperationalStatus() throws JsonParseException, JsonMappingException, IOException{
+ public void getE2EServiceInstanceNullOperationalStatus() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.GET);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatusCode().value());
}
@Test
- public void scaleE2EServiceInstanceMappingError() throws JsonParseException, JsonMappingException, IOException{
+ public void scaleE2EServiceInstanceMappingError() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale";
ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
@@ -145,22 +168,35 @@ private ObjectMapper mapper = new ObjectMapper();
assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
}
@Test
- public void scaleE2EServiceInstance() throws JsonParseException, JsonMappingException, IOException{
- RequestError expectedResponse = new RequestError();
- ServiceException exception = new ServiceException();
- exception.setMessageId("SVC1000");
- exception.setText("No communication to catalog DB null");
- expectedResponse.setServiceException(exception);
-
+ public void scaleE2EServiceInstance() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale";
ResponseEntity<String> response = sendRequest(inputStream("/ScaleRequest.json"), uri, HttpMethod.POST);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
- assertThat(realResponse, sameBeanAs(expectedResponse));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void updateE2EServiceInstance() throws IOException{
+ String uri = e2eServInstancesUri + "v3/9b9f02c0-298b-458a-bc9c-be3692e4f35e";
+ ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.PUT);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void getE2EServiceInstance() throws IOException{
+ OperationStatus status = new OperationStatus();
+ status.setOperationId("operationId");
+ status.setServiceId("9b9f02c0-298b-458a-bc9c-be3692e4f35e");
+ stubFor(get(urlPathEqualTo("/operationStatusRepository/search/findOneByServiceIdAndOperationId"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(status))
+ .withStatus(HttpStatus.SC_OK)));
+ String uri = e2eServInstancesUri + "v3/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/operationId";
+ ResponseEntity<String> response = sendRequest("", uri, HttpMethod.GET);
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
}
@Test
- public void compareModelWithTargetVersionBadRequest() throws JsonParseException, JsonMappingException, IOException{
+ public void compareModelWithTargetVersionBadRequest() throws IOException{
String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences";
ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST);
@@ -169,7 +205,7 @@ private ObjectMapper mapper = new ObjectMapper();
assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed"));
}
@Test
- public void compareModelWithTargetVersion() throws JsonParseException, JsonMappingException, IOException{
+ public void compareModelWithTargetVersion() throws IOException{
stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("Camunda/SuccessfulResponse.json").withStatus(org.apache.http.HttpStatus.SC_ACCEPTED)));
@@ -183,7 +219,7 @@ private ObjectMapper mapper = new ObjectMapper();
assertEquals(expectedResponse, actualResponse);
}
@Test
- public void compareModelWithTargetVersionEmptyResponse() throws JsonParseException, JsonMappingException, IOException{
+ public void compareModelWithTargetVersionEmptyResponse() throws IOException{
stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
@@ -201,7 +237,7 @@ private ObjectMapper mapper = new ObjectMapper();
assertThat(realResponse, sameBeanAs(expectedResponse));
}
@Test
- public void compareModelWithTargetVersionBadBpelResponse() throws JsonParseException, JsonMappingException, IOException{
+ public void compareModelWithTargetVersionBadBpelResponse() throws IOException{
stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
@@ -214,7 +250,7 @@ private ObjectMapper mapper = new ObjectMapper();
assertTrue(realResponse.getServiceException().getText().contains("Request Failed due to BPEL error with HTTP Status"));
}
@Test
- public void compareModelWithTargetVersionNoBPELResponse() throws JsonParseException, JsonMappingException, IOException{
+ public void compareModelWithTargetVersionNoBPELResponse() throws IOException{
stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance"))
.willReturn(aResponse().withHeader("Content-Type", "application/json")
.withBody("{}").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index c9d83efced..5d6aa43a9b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import java.io.IOException;
@@ -57,62 +58,80 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
public class ManualTasksTest extends BaseTest{
- private final String basePath = "/tasks/v1/";
-
-
-
- @Test
- public void testCreateOpEnvObjectMapperError() throws IOException {
- TestAppender.events.clear();
- stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
-
- String taskId = "55";
- TasksRequest taskReq = new TasksRequest();
- RequestDetails reqDetail = new RequestDetails();
- RequestInfo reqInfo = new RequestInfo();
- reqInfo.setRequestorId("testId");
- reqInfo.setSource("testSource");
- reqInfo.setResponseValue(ValidResponses.skip);
- reqDetail.setRequestInfo(reqInfo);
- taskReq.setRequestDetails(reqDetail);
-
- //expected response
- TaskRequestReference expectedResponse = new TaskRequestReference();
- expectedResponse.setTaskId(taskId);
-
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
- headers.set(MsoLogger.CLIENT_ID, "VID");
- HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
- ResponseEntity<String> response = restTemplate.exchange(
- builder.toUriString(),
- HttpMethod.POST, entity, String.class);
-
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class);
-
-
- //then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- assertThat(realResponse, sameBeanAs(expectedResponse));
- ILoggingEvent logEvent = TestAppender.events.get(0);
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertEquals("987654321", mdc.get(MsoLogger.REQUEST_ID));
- assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("987654321", response.getHeaders().get("X-TransactionID").get(0));
- MDC.remove(MsoLogger.CLIENT_ID);
-
- }
+ private final String basePath = "/tasks/v1/";
+
+
+
+ @Test
+ public void testCreateOpEnvObjectMapperError() throws IOException {
+ TestAppender.events.clear();
+ stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK)));
+
+ String taskId = "55";
+ TasksRequest taskReq = new TasksRequest();
+ RequestDetails reqDetail = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setRequestorId("testId");
+ reqInfo.setSource("testSource");
+ reqInfo.setResponseValue(ValidResponses.skip);
+ reqDetail.setRequestInfo(reqInfo);
+ taskReq.setRequestDetails(reqDetail);
+
+ //expected response
+ TaskRequestReference expectedResponse = new TaskRequestReference();
+ expectedResponse.setTaskId(taskId);
+
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete");
+ ResponseEntity<String> response = restTemplate.exchange(
+ builder.toUriString(),
+ HttpMethod.POST, entity, String.class);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class);
+
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ assertThat(realResponse, sameBeanAs(expectedResponse));
+
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.ENDTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
+ assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
+ assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index 7feea9a456..63dc96f485 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -192,6 +192,7 @@ public class MsoRequestTest extends BaseTest {
{"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/CloudConfigurationConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
{"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
{"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateAndCloudDelete, 7},
+ {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/ScaleOutNoCloudConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyLcpCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
{"No valid tenantId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
@@ -206,6 +207,7 @@ public class MsoRequestTest extends BaseTest {
{"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 6},
{"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 6},
{"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5},
+ {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid model-info is specified", mapper.readValue(inputStream("/ModelInfo/ModelInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid modelInvariantId format is specified", mapper.readValue(inputStream("/ModelInfo/InvalidModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 2},
{"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 4},
@@ -215,11 +217,14 @@ public class MsoRequestTest extends BaseTest {
{"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantIdConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 3},
{"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v5DeactivateModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 5},
{"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v3UpdateNetworkBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4},
+ {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/VfModuleModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, 4},
+ {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid modelType is specified", mapper.readValue(inputStream("/ModelInfo/ModelTypeNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3},
{"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
{"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionServiceCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
+ {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ConfigurationModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 4},
@@ -229,6 +234,7 @@ public class MsoRequestTest extends BaseTest {
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, 5},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionIdCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v5ActivateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
+ {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
//ValidationException for Platform and LineOfBusiness
{"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid platform is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 6},
@@ -261,6 +267,7 @@ public class MsoRequestTest extends BaseTest {
{"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5EnablePortNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5},
{"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5CreateNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v4RelatedInstancesNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4},
+ {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/ScaleOutNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid related service instance for vfModule request is specified", mapper.readValue(inputStream("/RelatedInstances/VfModuleRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
{"No valid related service instance for vnf request is specified", mapper.readValue(inputStream("/RelatedInstances/VnfRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
{"No valid related service instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesServiceInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5},
@@ -275,6 +282,7 @@ public class MsoRequestTest extends BaseTest {
{"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5},
{"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, 6},
{"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6},
+ {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/ScaleOutNoRequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7},
{"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/VnfProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
{"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3},
{"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3},
@@ -310,7 +318,9 @@ public class MsoRequestTest extends BaseTest {
{"No valid model-info in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/Network.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
{"No valid modelCustomizationId in userParams vfModule resources is specified", mapper.readValue(inputStream("/RequestParameters/VfModuleModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
{"No valid modelCustomizationId in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
- {"No valid modelCustomizationId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7}
+ {"No valid modelCustomizationId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7},
+ //Validation for ConfigurationParameters
+ {"No valid configuration parameters is specified", mapper.readValue(inputStream("/ConfigurationParameters/NoConfigurationParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}
});
}
@Test
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 1ab66561b0..48d424c8d1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -73,1335 +73,1386 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
public class ServiceInstancesTest extends BaseTest{
-
- @Autowired
- private InfraActiveRequestsRepository iar;
-
- @Autowired
- private ServiceInstances servInstances;
-
- private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
- private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
- private String uri;
-
- public String inputStream(String JsonInput)throws IOException{
- JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
- String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
- return input;
- }
-
- public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type",MediaType.APPLICATION_JSON);
-
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
-
- HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
- ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
- reqMethod, request, String.class);
-
- return response;
- }
-
- @Test
- public void test_mapJSONtoMSOStyle() throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- String testRequest= inputStream("/ServiceInstanceDefault.json");
- String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
- ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
- ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
- assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
- assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
- assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
- assertEquals("10",modelInfo.getModelUuid());
-
- }
- @Test
- public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{
- TestAppender.events.clear();
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
- headers.set(MsoLogger.CLIENT_ID, "VID");
- //expect
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- //then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- ILoggingEvent logEvent = TestAppender.events.get(0);
- Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(MsoLogger.REQUEST_ID));
- assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID));
- MDC.remove(MsoLogger.CLIENT_ID);
- assertTrue(response.getBody().contains("1882939"));
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", response.getHeaders().get("X-TransactionID").get(0));
+
+ @Autowired
+ private InfraActiveRequestsRepository iar;
+
+ @Autowired
+ private ServiceInstances servInstances;
+
+ private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
+ private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
+ private String uri;
+
+ public String inputStream(String JsonInput)throws IOException{
+ JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
+ String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
+ return input;
+ }
+
+ public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type",MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
+
+ HttpEntity<String> request = new HttpEntity<String>(requestJson, headers);
+ ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(),
+ reqMethod, request, String.class);
+
+ return response;
+ }
+
+ @Test
+ public void test_mapJSONtoMSOStyle() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
+ ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
+ assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
+ assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
+ assertEquals("10",modelInfo.getModelUuid());
+
+ }
+ @Test
+ public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{
+ TestAppender.events.clear();
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ headers.set(MsoLogger.CLIENT_ID, "VID");
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+
+
+
+ for(ILoggingEvent logEvent : TestAppender.events)
+ if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("ENTRY")
+ ){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
+ }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
+ logEvent.getMarker().getName().equals("EXIT")){
+ Map<String,String> mdc = logEvent.getMDCPropertyMap();
+ assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(MsoLogger.ENDTIME));
+ assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
+ assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
+ assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
+ assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
+ assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
+ assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
+ assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
+ assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
+ assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
+ }
- //ExpectedRecord
- InfraActiveRequests expectedRecord = new InfraActiveRequests();
- expectedRecord.setRequestStatus("IN_PROGRESS");
- expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json"));
- expectedRecord.setAction("createInstance");
- expectedRecord.setSource("VID");
- expectedRecord.setVnfId("1882938");
- expectedRecord.setLastModifiedBy("APIH");
- expectedRecord.setServiceInstanceId("1882939");
- expectedRecord.setServiceInstanceName("testService9");
- expectedRecord.setRequestScope("service");
- expectedRecord.setRequestorId("xxxxxx");
- expectedRecord.setRequestAction("createInstance");
- expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- //ActualRecord
- InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
- assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString());
-
- }
- @Test
- public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expect
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceUriPrev7 + "v5";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- //then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
-
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
-
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
-
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{
- uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
- headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST);
-
- //ExpectedRecord
- InfraActiveRequests expectedRecord = new InfraActiveRequests();
- expectedRecord.setRequestStatus("FAILED");
- expectedRecord.setAction("activateInstance");
- expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
- expectedRecord.setProgress(new Long(100));
- expectedRecord.setSource("VID");
- expectedRecord.setVnfId("1882938");
- expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
- expectedRecord.setLastModifiedBy("APIH");
- expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968");
- expectedRecord.setServiceInstanceName("testService7");
- expectedRecord.setRequestScope("service");
- expectedRecord.setRequestAction("activateInstance");
- expectedRecord.setRequestorId("xxxxxx");
- expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- //ActualRecord
- InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
- assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{
- uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/assign";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertTrue(response.getBody().contains("1882939"));
- }
- @Test
- public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException {
- uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void enablePort() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void disablePort() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void activatePort() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deactivatePort() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void addRelationships() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
- ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void removeRelationships() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
- ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
- ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
- headers.set(MsoLogger.TRANSACTION_ID, requestId);
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
- ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- InfraActiveRequests record = iar.findOneByRequestId(requestId);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertTrue(response.getBody().contains("1882939"));
- assertEquals(record.getVnfType(), "vSAMP12/test");
- }
- @Test
- public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException {
- uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
- ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- }
- @Test
- public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException {
- uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
- ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
- assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified"));
- }
- @Test
- public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
- ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
- ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
- logger.debug(response.getBody());
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
- ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
- headers.set(MsoLogger.TRANSACTION_ID, requestId);
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
- ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- InfraActiveRequests record = iar.findOneByRequestId(requestId);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertNull(record.getVnfType());
- }
- @Test
- public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
- ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
- ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertTrue(response.getBody().contains("1882939"));
- }
- @Test
- public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
- ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
- ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException {
- uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
- ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
- assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified"));
- }
- @Test
- public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
- ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
- ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
- logger.debug(response.getBody());
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{
- headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
- InfraActiveRequests expectedRecord = new InfraActiveRequests();
- expectedRecord.setRequestStatus("FAILED");
- expectedRecord.setAction("createInstance");
- expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
- expectedRecord.setProgress(new Long(100));
- expectedRecord.setSource("VID");
- expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
- expectedRecord.setLastModifiedBy("APIH");
- expectedRecord.setVfModuleName("testVfModule2");
- expectedRecord.setVfModuleModelName("serviceModel");
- expectedRecord.setRequestScope("vfModule");
- expectedRecord.setRequestAction("createInstance");
- expectedRecord.setRequestorId("zz9999");
- expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
- //VnfType is not sent in this request, should be blank in db
- expectedRecord.setVnfType("");
- uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
-
- ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST);
- //ActualRecord
- InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
- assertNotNull(requestRecord.getStartTime());
- assertNotNull(requestRecord.getEndTime());
- }
- @Test
- public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
- ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- InfraActiveRequests req = new InfraActiveRequests();
- req.setRequestStatus("IN_PROGRESS");
- req.setAction("inPlaceSoftwareUpdate");
- req.setProgress(new Long(10));
- req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
- req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908");
- req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033");
- req.setRequestScope("vnf");
- req.setVnfName("duplicateCheck123");
- req.setRequestAction("inPlaceSoftwareUpdate");
- req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
- iar.save(req);
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate";
- ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
-
- InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json"));
-
- assertNotNull(newRecord.getServiceInstanceId());
- assertNotNull(newRecord.getVnfId());
-
- }
-
- @Test
- public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
- ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
- ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
- ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertTrue(response.getBody().contains("1882939"));
- }
- @Test
- public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
- ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
- ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
- headers.set(MsoLogger.TRANSACTION_ID, requestId);
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- InfraActiveRequests record = iar.findOneByRequestId(requestId);
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertEquals(record.getNetworkType(), "TestNetworkType");
- }
- @Test
- public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
- ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- assertTrue(response.getBody().contains("1882939"));
- }
- @Test
- public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
- @Test
- public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException {
- headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
- //ExpectedRecord
- InfraActiveRequests expectedRecord = new InfraActiveRequests();
- expectedRecord.setRequestStatus("FAILED");
- expectedRecord.setStatusMessage("Error mapping request: ");
- expectedRecord.setProgress(new Long(100));
- expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
- expectedRecord.setLastModifiedBy("APIH");
- expectedRecord.setRequestScope("network");
- expectedRecord.setRequestAction("deleteInstance");
- expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
- ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE);
-
- //ActualRecord
- InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage"));
- assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: "));
- assertNotNull(requestRecord.getStartTime());
- assertNotNull(requestRecord.getEndTime());
- }
- @Test
- public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException {
- uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
- ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v7" + "/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- }
-
- @Test
- public void createNetworkInstanceTestApiGrApi() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void createNetworkInstanceTestApiVnfApi() throws IOException {
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
- ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
-
- //expected response
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
- headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- InfraActiveRequests expectedRecord = new InfraActiveRequests();
- expectedRecord.setRequestStatus("FAILED");
- expectedRecord.setAction("activateInstance");
- expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
- expectedRecord.setProgress(new Long(100));
- expectedRecord.setSource("VID");
- expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
- expectedRecord.setLastModifiedBy("APIH");
- expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999");
- expectedRecord.setServiceInstanceName("testService1234");
- expectedRecord.setRequestScope("service");
- expectedRecord.setRequestAction("activateInstance");
- expectedRecord.setRequestorId("xxxxxx");
- expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- //expect
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
-
- //then
- assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus());
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void invalidRequestId() throws IOException {
- String illegalRequestId = "1234";
- headers.set("X-ECOMP-RequestID", illegalRequestId);
-
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
-
- assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
- }
- @Test
- public void invalidBPELResponse() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
- assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
- }
-
- @Test
- public void invalidBPELResponse2() throws IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- uri = servInstanceuri + "v5/serviceInstances";
- ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
- assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
- }
-
- @Test
- public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{
- stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
-
- //expect
- ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
- RequestReferences requestReferences = new RequestReferences();
- requestReferences.setInstanceId("1882939");
- expectedResponse.setRequestReferences(requestReferences);
- uri = servInstanceUriPrev7 + "v5";
- ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- //then
- assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
- ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
- assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
- }
-
- @Test
- public void testUserParams() throws JsonParseException, JsonMappingException, IOException {
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
- RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
- String userParamsTxt = inputStream("/userParams.txt");
-
- List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
- System.out.println(userParams);
- assertTrue(userParams.size() > 0);
- assertTrue(userParams.get(0).containsKey("name"));
- assertTrue(userParams.get(0).containsKey("value"));
- assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+","")));
- }
-
- @Test
- public void testConfigureCloudConfig() throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
- CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
-
- assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
- assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
- }
-
- @Test
- public void testMapToLegacyRequest() throws IOException {
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
- ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
- servInstances.mapToLegacyRequest(request.getRequestDetails());
- System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
- assertThat(request, sameBeanAs(expected));
- }
+ //ExpectedRecord
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("IN_PROGRESS");
+ expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json"));
+ expectedRecord.setAction("createInstance");
+ expectedRecord.setSource("VID");
+ expectedRecord.setVnfId("1882938");
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setServiceInstanceId("1882939");
+ expectedRecord.setServiceInstanceName("testService9");
+ expectedRecord.setRequestScope("service");
+ expectedRecord.setRequestorId("xxxxxx");
+ expectedRecord.setRequestAction("createInstance");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString());
+
+ }
+ @Test
+ public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceUriPrev7 + "v5";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createServiceInstanceBadData() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{I AM REALLY BAD}")));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
+ headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST);
+
+ //ExpectedRecord
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setAction("activateInstance");
+ expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setSource("VID");
+ expectedRecord.setVnfId("1882938");
+ expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968");
+ expectedRecord.setServiceInstanceName("testService7");
+ expectedRecord.setRequestScope("service");
+ expectedRecord.setRequestAction("activateInstance");
+ expectedRecord.setRequestorId("xxxxxx");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/assign";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void enablePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void disablePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void activatePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deactivatePort() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void addRelationships() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
+ ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void removeRelationships() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
+ ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
+ headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests record = iar.findOneByRequestId(requestId);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ assertEquals(record.getVnfType(), "vSAMP12/test");
+ }
+ @Test
+ public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+ @Test
+ public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
+ ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified"));
+ }
+ @Test
+ public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+ ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+ ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
+ logger.debug(response.getBody());
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
+ headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
+ ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests record = iar.findOneByRequestId(requestId);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertNull(record.getVnfType());
+ }
+ @Test
+ public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified"));
+ }
+ @Test
+ public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+ ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
+ logger.debug(response.getBody());
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setAction("createInstance");
+ expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setSource("VID");
+ expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setVfModuleName("testVfModule2");
+ expectedRecord.setVfModuleModelName("serviceModel");
+ expectedRecord.setRequestScope("vfModule");
+ expectedRecord.setRequestAction("createInstance");
+ expectedRecord.setRequestorId("zz9999");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //VnfType is not sent in this request, should be blank in db
+ expectedRecord.setVnfType("");
+ uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
+
+ ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST);
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString());
+ assertNotNull(requestRecord.getStartTime());
+ assertNotNull(requestRecord.getEndTime());
+ }
+ @Test
+ public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
+ ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setRequestStatus("IN_PROGRESS");
+ req.setAction("inPlaceSoftwareUpdate");
+ req.setProgress(new Long(10));
+ req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
+ req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908");
+ req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033");
+ req.setRequestScope("vnf");
+ req.setVnfName("duplicateCheck123");
+ req.setRequestAction("inPlaceSoftwareUpdate");
+ req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+ iar.save(req);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate";
+ ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
+
+ InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json"));
+
+ assertNotNull(newRecord.getServiceInstanceId());
+ assertNotNull(newRecord.getVnfId());
+
+ }
+
+ @Test
+ public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
+ ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
+ ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
+ headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests record = iar.findOneByRequestId(requestId);
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertEquals(record.getNetworkType(), "TestNetworkType");
+ }
+ @Test
+ public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
+ @Test
+ public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+ @Test
+ public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException {
+ headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+ //ExpectedRecord
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setStatusMessage("Error mapping request: ");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setRequestScope("network");
+ expectedRecord.setRequestAction("deleteInstance");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
+ ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE);
+
+ //ActualRecord
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage"));
+ assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: "));
+ assertNotNull(requestRecord.getStartTime());
+ assertNotNull(requestRecord.getEndTime());
+ }
+ @Test
+ public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException {
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
+ ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiGrApi() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void createNetworkInstanceTestApiVnfApi() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
+ ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+ headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ InfraActiveRequests expectedRecord = new InfraActiveRequests();
+ expectedRecord.setRequestStatus("FAILED");
+ expectedRecord.setAction("activateInstance");
+ expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB.");
+ expectedRecord.setProgress(new Long(100));
+ expectedRecord.setSource("VID");
+ expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"));
+ expectedRecord.setLastModifiedBy("APIH");
+ expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999");
+ expectedRecord.setServiceInstanceName("testService1234");
+ expectedRecord.setRequestScope("service");
+ expectedRecord.setRequestAction("activateInstance");
+ expectedRecord.setRequestorId("xxxxxx");
+ expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
+
+ //then
+ assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus());
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void invalidRequestId() throws IOException {
+ String illegalRequestId = "1234";
+ headers.set("X-ECOMP-RequestID", illegalRequestId);
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
+ }
+ @Test
+ public void invalidBPELResponse() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
+ }
+
+ @Test
+ public void invalidBPELResponse2() throws IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
+ }
+
+ @Test
+ public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{
+ stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expect
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceUriPrev7 + "v5";
+ ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ //then
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ }
+
+ @Test
+ public void testUserParams() throws JsonParseException, JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
+ RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
+ String userParamsTxt = inputStream("/userParams.txt");
+
+ List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
+ System.out.println(userParams);
+ assertTrue(userParams.size() > 0);
+ assertTrue(userParams.get(0).containsKey("name"));
+ assertTrue(userParams.get(0).containsKey("value"));
+ assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+","")));
+ }
+
+ @Test
+ public void testConfigureCloudConfig() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
+ CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
+
+ assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
+ assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
+ }
+
+ @Test
+ public void testMapToLegacyRequest() throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
+ ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
+ servInstances.mapToLegacyRequest(request.getRequestDetails());
+ System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
+ assertThat(request, sameBeanAs(expected));
+ }
+ @Test
+ public void scaleOutVfModule() throws JsonParseException, JsonMappingException, IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ expectedResponse.setRequestReferences(requestReferences);
+ uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
+ ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+ ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
+ assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+ assertTrue(response.getBody().contains("1882939"));
+ }
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json
index 18b785cae5..57aea4d2bb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json
@@ -32,7 +32,7 @@
],
"requestParameters": {
"autoBuildVfModules": false,
- "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
}
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json
index bd114f7ad8..e876711c66 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json
@@ -35,7 +35,7 @@
],
"requestParameters": {
"autoBuildVfModules": false,
- "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
}
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json
new file mode 100644
index 0000000000..1cc91500f0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json
@@ -0,0 +1,50 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json
new file mode 100644
index 0000000000..2f3f42e135
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json
@@ -0,0 +1,54 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json
new file mode 100644
index 0000000000..d1220ad949
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json
@@ -0,0 +1,53 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json
new file mode 100644
index 0000000000..9447250ef6
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json
@@ -0,0 +1,53 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json
new file mode 100644
index 0000000000..ca60ffcf41
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json
@@ -0,0 +1,53 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json
new file mode 100644
index 0000000000..b9914d374b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json
@@ -0,0 +1,53 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json
new file mode 100644
index 0000000000..b4afcda4cf
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json
@@ -0,0 +1,53 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json
new file mode 100644
index 0000000000..b9914d374b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json
@@ -0,0 +1,53 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "requestInfo": {
+ "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1",
+ "source": "VID",
+ "suppressRollback": false,
+ "requestorId": "xxxxxx"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json
new file mode 100644
index 0000000000..47f49a728a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json
@@ -0,0 +1,34 @@
+{
+ "requestDetails":{
+ "modelInfo":{
+ "modelType":"vfModule",
+ "modelInvariantId":"ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId":"fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelCustomizationId":"cb82ffd8-252a-11e7-93ae-92361f002672",
+ "modelName":"vSAMP12..base..module-0",
+ "modelVersion":"1"
+ },
+ "cloudConfiguration":{
+ "lcpCloudRegionId":"mdt1",
+ "tenantId":"88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo":{
+ "instanceName":"MSOTEST103a-vSAMP12_base_module-0",
+ "source":"VID",
+ "suppressRollback":true,
+ "requestorId":"xxxxxx"
+ },
+ "requestParameters":{
+ "usePreload":true,
+ "userParams":[
+
+ ]
+ },
+ "configurationParameters":[
+ {
+ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json
index b1c9e65bba..c917a9504e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json
@@ -36,7 +36,7 @@
],
"requestParameters": {
"autoBuildVfModules": false,
- "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
}
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json
index 484f7bfc97..39cba3cfc8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json
@@ -29,7 +29,7 @@
],
"requestParameters": {
"autoBuildVfModules": false,
- "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
}
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json
index 8562be02b8..dbf47112f3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json
@@ -35,7 +35,7 @@
],
"requestParameters": {
"autoBuildVfModules": false,
- "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
}
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json
new file mode 100644
index 0000000000..d403cc2af9
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json
@@ -0,0 +1,48 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "vSAMP10aDEV::base::module-0",
+ "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671",
+ "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671",
+ "modelVersion": "2",
+ "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mtn6",
+ "tenantId": "0422ffb57ba042c0800a29dc85ca70f8"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "MSOTADevInfra_vSAMP10a_Service",
+ "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671",
+ "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "vSAMP10a",
+ "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e",
+ "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671",
+ "modelVersion": "1.0",
+ "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671",
+ "modelCustomizationName": "vSAMP10a 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "usePreload": true,
+ "userParams": []
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json
index 476b9367c1..9a21a23ca0 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json
@@ -36,7 +36,7 @@
],
"requestParameters": {
"autoBuildVfModules": false,
- "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}"
+ "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}"
}
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json
new file mode 100644
index 0000000000..ba5a8a92e5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json
@@ -0,0 +1,71 @@
+{
+ "requestDetails":{
+ "modelInfo":{
+ "modelType":"vfModule",
+ "modelInvariantId":"ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId":"fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelCustomizationId":"cb82ffd8-252a-11e7-93ae-92361f002672",
+ "modelName":"vSAMP12..base..module-0",
+ "modelVersion":"1"
+ },
+ "cloudConfiguration":{
+ "lcpCloudRegionId":"mdt1",
+ "tenantId":"88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo":{
+ "instanceName":"MSOTEST103a-vSAMP12_base_module-0",
+ "source":"VID",
+ "suppressRollback":true,
+ "requestorId":"xxxxxx"
+ },
+ "relatedInstanceList":[
+ {
+ "relatedInstance":{
+ "instanceId":"cbba721b-4803-4df7-9347-307c9a955426",
+ "instanceName":"MSOTESTVOL103a-vSAMP12_base_module-0_vol",
+ "modelInfo":{
+ "modelType":"volumeGroup"
+ }
+ }
+ },
+ {
+ "relatedInstance":{
+ "instanceId":"7a88cbeb-0ec8-4765-a271-4f9e90c3da7b",
+ "modelInfo":{
+ "modelType":"service",
+ "modelInvariantId":"ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId":"fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName":"{parent service model name}",
+ "modelVersion":"1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance":{
+ "instanceId":"cbba721b-4803-4df7-9347-307c9a955426",
+ "modelInfo":{
+ "modelType":"vnf",
+ "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff",
+ "modelVersionId":"fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName":"vSAMP12",
+ "modelVersion":"1.0",
+ "modelCustomizationName":"vSAMP12 1",
+ "modelCustomizationId":"a7f1d08e-b02d-11e6-80f5-76304dec7eb7"
+ }
+ }
+ }
+ ],
+ "requestParameters":{
+ "usePreload":true,
+ "userParams":[
+
+ ]
+ },
+ "configurationParameters":[
+ {
+ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
index c5b3b70723..b7b6a8c1cb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
@@ -29,7 +29,7 @@ mso:
catalog:
db:
spring:
- endpoint: "http://localhost:"
+ endpoint: http://localhost:${wiremock.server.port}
db:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
config:
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql
index 54984eeabb..70c0791055 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql
@@ -224,8 +224,7 @@ INSERT INTO vnf_components_recipe(ID, VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, SERV
('19', 'vfModule', 'vfModule', 'createInstance', '', '1', 'VID_DEFAULT recipe to create vf-module if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleInfra', '', '180', '2016-09-14 19:18:20', '20c4431c-246d-11e7-93ae-92361f002672'),
('20', 'vfModule', 'vfModule', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete vf-module if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'),
('21', 'vfModule', 'vfModule', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update vf-module if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'),
-('25', 'vfModule', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT');
-
+('25', 'vfModule', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT');
INSERT INTO catalogdb.network_recipe(ID, MODEL_NAME, ACTION, DESCRIPTION, ORCHESTRATION_URI, NETWORK_PARAM_XSD, RECIPE_TIMEOUT, SERVICE_TYPE, CREATION_TIMESTAMP, VERSION_STR) VALUES
('17', 'VID_DEFAULT', 'createInstance', 'VID_DEFAULT recipe to create network if no custom BPMN flow is found', '/mso/async/services/CreateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'),
@@ -274,7 +273,9 @@ VALUES
('vfModule', 'deleteInstance', '1', 'Gr api recipe to delete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'),
('vfModule', 'updateInstance', '1', 'Gr api recipe to update vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'),
('vfModule', 'replaceInstance', '1', 'Gr api recipe to replace vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'),
-('vfModule', 'deactivateAndCloudDelete', '1', 'Gr api recipe to deactivateAndCloudDelete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT');
+('vfModule', 'deactivateAndCloudDelete', '1', 'Gr api recipe to deactivateAndCloudDelete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'),
+('vfModule', 'scaleOut', '1', 'Gr api recipe to scale out vfModule', '/mso/async/services/WorkflowActionBB', '180', 'GR-API-DEFAULT');
+
UPDATE vnf_components_recipe
SET vf_module_model_uuid = 'VNF-API-DEFAULT'
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml
index 1b3a7cc6da..4da57a15f9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml
@@ -1,39 +1,41 @@
-<configuration >
-
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n
+<configuration>
+
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n
</pattern>
- </encoder>
- </appender>
- <appender name="test" class="org.onap.so.apihandlerinfra.TestAppender"/>
-
-
- <logger name="AUDIT" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- <appender-ref ref = "test" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.error" level="ERROR" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false">
+ </encoder>
+ </appender>
+ <appender name="test" class="org.onap.so.apihandlerinfra.TestAppender" />
+
+
+ <logger name="AUDIT" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.error" level="ERROR" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
-
- <logger name="com.att" level="${so.log.level:-DEBUG}" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
- <root level="WARN">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger name="wiremock.org" level="ERROR" />
+
+ <logger name="org.onap" level="${so.log.level:-DEBUG}"
+ additivity="false">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="test" />
+ </logger>
+
+ <logger name="com.att" level="${so.log.level:-DEBUG}"
+ additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="wiremock.org" level="ERROR" />
</configuration> \ No newline at end of file