summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java83
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java348
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponse.json21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json51
6 files changed, 293 insertions, 234 deletions
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 8c00eb06b4..66b04b6fdb 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
@@ -44,6 +44,7 @@ import org.onap.so.apihandler.common.ResponseHandler;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
@@ -51,6 +52,7 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.Recipe;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.beans.VfModule;
@@ -82,8 +84,17 @@ import org.onap.so.serviceinstancebeans.Vnfs;
import org.onap.so.utils.UUIDChecker;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestTemplate;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
@@ -135,6 +146,9 @@ public class ServiceInstances {
@Autowired
private MsoRequest msoRequest;
+ @Autowired
+ private RestTemplate restTemplate;
+
@POST
@Path("/{version:[vV][5-7]}/serviceInstances")
@Consumes(MediaType.APPLICATION_JSON)
@@ -718,11 +732,15 @@ public class ServiceInstances {
}
InfraActiveRequests dup = null;
-
+ boolean inProgress = false;
dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
- if (dup != null) {
+ if(dup != null){
+ inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ }
+
+ if (dup != null && inProgress) {
buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
}
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -881,8 +899,13 @@ public class ServiceInstances {
}
InfraActiveRequests dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq);
-
- if (dup != null) {
+ boolean inProgress = false;
+
+ if(dup != null){
+ inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ }
+
+ if (dup != null && inProgress) {
buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup);
}
@@ -1149,6 +1172,42 @@ public class ServiceInstances {
}
return dup;
}
+ protected boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) throws RequestDbFailureException, ContactCamundaException{
+ String requestId = duplicateRecord.getRequestId();
+ String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
+ String targetUrl = env.getProperty("mso.camundaURL") + path;
+ HttpHeaders headers = setHeaders(env.getProperty("mso.camundaAuth"));
+ HttpEntity<?> requestEntity = new HttpEntity<>(headers);
+ ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
+ try{
+ response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>(){});
+ }catch(HttpStatusCodeException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ContactCamundaException contactCamundaException= new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage());
+ throw contactCamundaException;
+ }
+ if(response.getBody().isEmpty()){
+ updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
+ }
+ for(HistoricProcessInstance instance : response.getBody()){
+ if(instance.getState().equals("ACTIVE")){
+ return true;
+ }else{
+ updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
+ }
+ }
+ return false;
+ }
+ private HttpHeaders setHeaders(String auth) {
+ HttpHeaders headers = new HttpHeaders();
+ List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
+ acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
+ headers.setAccept(acceptableMediaTypes);
+ headers.add(HttpHeaders.AUTHORIZATION, auth);
+ return headers;
+ }
private ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime,
ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException {
@@ -1672,7 +1731,9 @@ public class ServiceInstances {
Recipe recipe = null;
if(modelInfo.getModelCustomizationId()!=null){
- NetworkResource networkResource = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource();
+ NetworkResourceCustomization networkResourceCustomization = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId());
+ if(networkResourceCustomization != null){
+ NetworkResource networkResource = networkResourceCustomization.getNetworkResource();
if(networkResource!=null){
if(modelInfo.getModelVersionId() == null) {
modelInfo.setModelVersionId(networkResource.getModelUUID());
@@ -1681,6 +1742,9 @@ public class ServiceInstances {
}else{
throw new ValidationException("no catalog entry found");
}
+ }else if(action != Action.deleteInstance){
+ throw new ValidationException("modelCustomizationId for networkResourceCustomization lookup", true);
+ }
}else{
//ok for version < 3 and action delete
if(modelName != null){
@@ -1733,6 +1797,7 @@ public class ServiceInstances {
String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
Boolean aLaCarte = null;
String apiVersion = version.substring(1);
+ boolean inProgress = false;
long startTime = System.currentTimeMillis ();
ServiceInstancesRequest sir = null;
@@ -1750,8 +1815,12 @@ public class ServiceInstances {
InfraActiveRequests dup = null;
dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+
+ if(dup != null){
+ inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ }
- if (instanceIdMap != null && dup != null) {
+ if (instanceIdMap != null && dup != null && inProgress) {
buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
}
@@ -1829,7 +1898,7 @@ public class ServiceInstances {
return postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope);
}
- public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
+ public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
String requestId = null;
if (requestContext.getProperty("requestId") != null) {
requestId = requestContext.getProperty("requestId").toString();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
index 5b52d33cdd..a4c0c45fb3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
@@ -23,7 +23,8 @@ mso:
rest:
task:
uri: /sobpmnengine/task
-
+ history:
+ uri: /sobpmnengine/history/process-instance?variables=mso-request-id_eq_
spring:
datasource:
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 f84c2be898..18bcc82a32 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
@@ -29,6 +29,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
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.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -52,6 +53,8 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
+import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -87,6 +90,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent;
public class ServiceInstancesTest extends BaseTest{
private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectMapper errorMapper = new ObjectMapper();
@Autowired
private ServiceInstances servInstances;
@@ -104,6 +108,9 @@ public class ServiceInstancesTest extends BaseTest{
@Before
public void beforeClass() {
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
// set headers
headers = new HttpHeaders();
headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
@@ -218,9 +225,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
- 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);
@@ -290,9 +294,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceUriPrev7 + "v5";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
- 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);
@@ -461,9 +462,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -508,9 +506,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -553,9 +548,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
- 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"));
@@ -598,9 +590,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/assign";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -644,9 +633,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -665,9 +651,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -695,9 +678,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -716,9 +696,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -737,9 +714,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -758,9 +732,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -779,9 +750,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -800,9 +768,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -821,9 +786,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -859,9 +821,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -901,9 +860,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -920,13 +876,9 @@ public class ServiceInstancesTest extends BaseTest{
public void createVnfInstanceInvalidVnfResource() throws 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);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
}
@Test
@@ -958,9 +910,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -995,8 +944,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
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);
@@ -1032,8 +979,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
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);
@@ -1070,9 +1015,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1099,9 +1041,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1125,17 +1064,13 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
-
- 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 IOException {
-
stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
@@ -1169,9 +1104,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1285,6 +1217,7 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
+
assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
ObjectMapper mapper = new ObjectMapper();
@@ -1318,11 +1251,9 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
-
+
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);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
}
@Test
@@ -1351,9 +1282,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1395,9 +1323,6 @@ public class ServiceInstancesTest extends BaseTest{
ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
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"));
@@ -1447,9 +1372,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1482,9 +1404,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1510,9 +1429,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
- 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"));
@@ -1543,10 +1459,7 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
-
- 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"));
@@ -1582,9 +1495,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1621,9 +1531,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1662,10 +1569,7 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
-
- 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"));
@@ -1701,9 +1605,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -1738,9 +1639,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1777,9 +1675,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1806,9 +1701,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -1876,9 +1768,6 @@ public class ServiceInstancesTest extends BaseTest{
requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
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"));
@@ -1916,9 +1805,6 @@ public class ServiceInstancesTest extends BaseTest{
requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
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"));
@@ -1939,9 +1825,6 @@ public class ServiceInstancesTest extends BaseTest{
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());
}
@@ -1977,9 +1860,6 @@ public class ServiceInstancesTest extends BaseTest{
requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
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"));
@@ -2017,9 +1897,6 @@ public class ServiceInstancesTest extends BaseTest{
requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
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"));
@@ -2059,9 +1936,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
- 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"));
@@ -2106,13 +1980,9 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
-
- 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);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
}
@Test
@@ -2144,12 +2014,8 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
}
@@ -2180,13 +2046,9 @@ public class ServiceInstancesTest extends BaseTest{
.withStatus(HttpStatus.SC_OK)));
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
-
- 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);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
}
@@ -2228,9 +2090,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceUriPrev7 + "v5";
ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
- 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);
@@ -2311,9 +2170,6 @@ public class ServiceInstancesTest extends BaseTest{
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, headers);
- 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"));
@@ -2346,13 +2202,9 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
+
assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
}
@Test
@@ -2363,15 +2215,59 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+ assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
+ }
+ @Test
+ public void createServiceInstanceDuplicateHistoryCheck() throws IOException{
+ stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
+ .withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
+
+ assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+ assertEquals("Error: Locked instance - This service (testService9) already has a request being worked with a status of UNLOCKED (RequestId - f0a35706-efc4-4e27-80ea-a995d7a2a40f). The existing request must finish or be cleaned up before proceeding.", realResponse.getServiceException().getText());
+ }
+ @Test
+ public void createServiceInstanceDuplicateHistoryCheckException() throws IOException{
+ stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
+ .withStatus(HttpStatus.SC_ACCEPTED)));
+ stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
+
+ assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+ assertEquals("Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
+ }
+ @Test
+ public void createServiceInstanceDuplicate() throws IOException{
+ stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
+
+ uri = servInstanceuri + "v5/serviceInstances";
+ ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
}
+
@Test
public void createServiceInstanceSaveError() throws IOException{
ServiceRecipe serviceRecipe = new ServiceRecipe();
@@ -2398,12 +2294,8 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5/serviceInstances";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
}
@Test
@@ -2417,13 +2309,9 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
+
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
}
@Test
@@ -2434,13 +2322,9 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
+
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
}
@Test
@@ -2474,9 +2358,6 @@ public class ServiceInstancesTest extends BaseTest{
expectedResponse.setRequestReferences(requestReferences);
uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
-
- 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);
@@ -2506,9 +2387,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "/v7/instanceGroups";
ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
- 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);
@@ -2529,9 +2407,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
- 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);
@@ -2541,14 +2416,9 @@ public class ServiceInstancesTest extends BaseTest{
public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
//then
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
}
@Test
@@ -2557,14 +2427,9 @@ public class ServiceInstancesTest extends BaseTest{
noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
//then
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
}
@Test
@@ -2579,14 +2444,10 @@ public class ServiceInstancesTest extends BaseTest{
expectedResponse.setRequestReferences(requestReferences);
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
+
//then
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
- RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
}
@Test
@@ -2603,9 +2464,6 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
- 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);
@@ -2625,15 +2483,55 @@ public class ServiceInstancesTest extends BaseTest{
uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
- 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 deleteNetworkInstanceNoCustomizationEntry() throws IOException {
+ stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+
+ stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
+ "modelName=VNF-API-DEFAULT&action=deleteInstance"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
+ .withStatus(org.apache.http.HttpStatus.SC_OK)));
+
+ //expected response
+ ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
+ RequestReferences requestReferences = new RequestReferences();
+ requestReferences.setInstanceId("1882939");
+ requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
+ 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, headers);
+
+ 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 updateNetworkInstanceNoCustomizationEntry() throws IOException {
+ stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+
+ 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, headers);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+ assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
+ }
+
+ @Test
public void setServiceTypeTestALaCarte() throws JsonProcessingException{
String requestScope = ModelType.service.toString();
Boolean aLaCarteFlag = true;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponse.json
new file mode 100644
index 0000000000..196c71e010
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponse.json
@@ -0,0 +1,21 @@
+[
+ {
+ "id":"d1a0456e-1458-11e9-8afb-0242ac190006",
+ "businessKey":null,
+ "processDefinitionId":"86cfa113-141a-11e9-8afb-0242ac190006",
+ "processDefinitionKey":"UnassignServiceInstanceATTBB",
+ "processDefinitionName":"UnassignServiceInstanceATTBB",
+ "processDefinitionVersion":1,
+ "startTime":"2019-01-09T21:52:11.813+0000",
+ "endTime":"2019-01-09T21:52:12.353+0000",
+ "durationInMillis":540,
+ "startUserId":null,
+ "startActivityId":"Start_UnassignServiceInstanceBB",
+ "deleteReason":null,
+ "superProcessInstanceId":"d15f6c9e-1458-11e9-8afb-0242ac190006",
+ "superCaseInstanceId":null,
+ "caseInstanceId":null,
+ "tenantId":null,
+ "state":"ACTIVE"
+ }
+] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json
new file mode 100644
index 0000000000..fdf0e9a286
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json
@@ -0,0 +1,21 @@
+[
+ {
+ "id":"d1a0456e-1458-11e9-8afb-0242ac190006",
+ "businessKey":null,
+ "processDefinitionId":"86cfa113-141a-11e9-8afb-0242ac190006",
+ "processDefinitionKey":"UnassignServiceInstanceATTBB",
+ "processDefinitionName":"UnassignServiceInstanceATTBB",
+ "processDefinitionVersion":1,
+ "startTime":"2019-01-09T21:52:11.813+0000",
+ "endTime":"2019-01-09T21:52:12.353+0000",
+ "durationInMillis":540,
+ "startUserId":null,
+ "startActivityId":"Start_UnassignServiceInstanceBB",
+ "deleteReason":null,
+ "superProcessInstanceId":"d15f6c9e-1458-11e9-8afb-0242ac190006",
+ "superCaseInstanceId":null,
+ "caseInstanceId":null,
+ "tenantId":null,
+ "state":"COMPLETED"
+ }
+] \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json
index 822d847cf6..6be015694c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/InfraActiveRequests/createInfraActiveRequests.json
@@ -1 +1,50 @@
-{"requestId":"%1$s","clientRequestId":null,"action":"activateInstance","requestStatus":"UNLOCKED","statusMessage":null,"progress":20,"startTime":1506422369000,"endTime":null,"source":"VID","vnfId":null,"vnfName":null,"vnfType":null,"serviceType":null,"aicNodeClli":null,"tenantId":null,"provStatus":null,"vnfParams":null,"vnfOutputs":null,"requestBody":"{\"modelInfo\":{\"modelCustomizationName\":null,\"modelInvariantId\":\"1587cf0e-f12f-478d-8530-5c55ac578c39\",\"modelType\":\"configuration\",\"modelNameVersionId\":null,\"modelName\":null,\"modelVersion\":null,\"modelCustomizationUuid\":null,\"modelVersionId\":\"36a3a8ea-49a6-4ac8-b06c-89a545444455\",\"modelCustomizationId\":\"68dc9a92-214c-11e7-93ae-92361f002671\",\"modelUuid\":null,\"modelInvariantUuid\":null,\"modelInstanceName\":null},\"requestInfo\":{\"billingAccountNumber\":null,\"callbackUrl\":null,\"correlator\":null,\"orderNumber\":null,\"productFamilyId\":null,\"orderVersion\":null,\"source\":\"VID\",\"instanceName\":null,\"suppressRollback\":false,\"requestorId\":\"xxxxxx\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceName\":null,\"instanceId\":\"9e15a443-af65-4f05-9000-47ae495e937d\",\"modelInfo\":{\"modelCustomizationName\":null,\"modelInvariantId\":\"de19ae10-9a25-11e7-abc4-cec278b6b50a\",\"modelType\":\"service\",\"modelNameVersionId\":null,\"modelName\":\"Infra_Configuration_Service\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":null,\"modelVersionId\":\"ee938612-9a25-11e7-abc4-cec278b6b50a\",\"modelCustomizationId\":null,\"modelUuid\":null,\"modelInvariantUuid\":null,\"modelInstanceName\":null},\"instanceDirection\":null}}],\"subscriberInfo\":null,\"cloudConfiguration\":{\"aicNodeClli\":null,\"tenantId\":null,\"lcpCloudRegionId\":\"n6\"},\"requestParameters\":{\"subscriptionServiceType\":null,\"userParams\":[],\"aLaCarte\":false,\"autoBuildVfModules\":false,\"cascadeDelete\":false,\"usePreload\":true},\"project\":null,\"owningEntity\":null,\"platform\":null,\"lineOfBusiness\":null}","responseBody":null,"lastModifiedBy":"APIH","modifyTime":1532945172000,"requestType":null,"volumeGroupId":null,"volumeGroupName":null,"vfModuleId":null,"vfModuleName":null,"vfModuleModelName":null,"aaiServiceId":null,"aicCloudRegion":"n6","callBackUrl":null,"correlator":null,"serviceInstanceId":"9e15a443-af65-4f05-9000-47ae495e937d","serviceInstanceName":null,"requestScope":"configuration","requestAction":"activateInstance","networkId":null,"networkName":null,"networkType":null,"requestorId":"xxxxxx","configurationId":"26ef7f15-57bb-48df-8170-e59edc26234c","configurationName":null,"operationalEnvId":null,"operationalEnvName":null,"handler":{},"requestURI":"http://localhost:8087/infraActiveRequests/%1$s"}
+{
+ "requestId":"f0a35706-efc4-4e27-80ea-a995d7a2a40f",
+ "clientRequestId":null,
+ "action":"activateInstance",
+ "requestStatus":"UNLOCKED",
+ "statusMessage":null,
+ "progress":20,
+ "startTime":1506422369000,
+ "endTime":null,
+ "source":"VID",
+ "vnfId":null,
+ "vnfName":null,
+ "vnfType":null,
+ "serviceType":null,
+ "aicNodeClli":null,
+ "tenantId":null,
+ "provStatus":null,
+ "vnfParams":null,
+ "vnfOutputs":null,
+ "requestBody":"{\"modelInfo\":{\"modelCustomizationName\":null,\"modelInvariantId\":\"1587cf0e-f12f-478d-8530-5c55ac578c39\",\"modelType\":\"configuration\",\"modelNameVersionId\":null,\"modelName\":null,\"modelVersion\":null,\"modelCustomizationUuid\":null,\"modelVersionId\":\"36a3a8ea-49a6-4ac8-b06c-89a545444455\",\"modelCustomizationId\":\"68dc9a92-214c-11e7-93ae-92361f002671\",\"modelUuid\":null,\"modelInvariantUuid\":null,\"modelInstanceName\":null},\"requestInfo\":{\"billingAccountNumber\":null,\"callbackUrl\":null,\"correlator\":null,\"orderNumber\":null,\"productFamilyId\":null,\"orderVersion\":null,\"source\":\"VID\",\"instanceName\":null,\"suppressRollback\":false,\"requestorId\":\"xxxxxx\"},\"relatedInstanceList\":[{\"relatedInstance\":{\"instanceName\":null,\"instanceId\":\"9e15a443-af65-4f05-9000-47ae495e937d\",\"modelInfo\":{\"modelCustomizationName\":null,\"modelInvariantId\":\"de19ae10-9a25-11e7-abc4-cec278b6b50a\",\"modelType\":\"service\",\"modelNameVersionId\":null,\"modelName\":\"Infra_Configuration_Service\",\"modelVersion\":\"1.0\",\"modelCustomizationUuid\":null,\"modelVersionId\":\"ee938612-9a25-11e7-abc4-cec278b6b50a\",\"modelCustomizationId\":null,\"modelUuid\":null,\"modelInvariantUuid\":null,\"modelInstanceName\":null},\"instanceDirection\":null}}],\"subscriberInfo\":null,\"cloudConfiguration\":{\"aicNodeClli\":null,\"tenantId\":null,\"lcpCloudRegionId\":\"n6\"},\"requestParameters\":{\"subscriptionServiceType\":null,\"userParams\":[],\"aLaCarte\":false,\"autoBuildVfModules\":false,\"cascadeDelete\":false,\"usePreload\":true},\"project\":null,\"owningEntity\":null,\"platform\":null,\"lineOfBusiness\":null}",
+ "responseBody":null,
+ "lastModifiedBy":"APIH",
+ "modifyTime":1532945172000,
+ "requestType":null,
+ "volumeGroupId":null,
+ "volumeGroupName":null,
+ "vfModuleId":null,
+ "vfModuleName":null,
+ "vfModuleModelName":null,
+ "aaiServiceId":null,
+ "aicCloudRegion":"n6",
+ "callBackUrl":null,
+ "correlator":null,
+ "serviceInstanceId":"9e15a443-af65-4f05-9000-47ae495e937d",
+ "serviceInstanceName":null,
+ "requestScope":"configuration",
+ "requestAction":"activateInstance",
+ "networkId":null,
+ "networkName":null,
+ "networkType":null,
+ "requestorId":"xxxxxx",
+ "configurationId":"26ef7f15-57bb-48df-8170-e59edc26234c",
+ "configurationName":null,
+ "operationalEnvId":null,
+ "operationalEnvName":null,
+ "handler":{
+
+ },
+ "requestURI":"http://localhost:8087/infraActiveRequests/%1$s"
+} \ No newline at end of file