Merge "add junit coverage"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / ServiceInstancesTest.java
index 4b2644b..9f74278 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -29,21 +29,13 @@ 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.assertNull;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
+import static org.onap.logging.filter.base.Constants.HttpHeaders.CLIENT_ID;
+import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
+import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID;
 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
-import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
-import static org.onap.so.logger.MdcConstants.CLIENT_ID;
-import static org.onap.so.logger.MdcConstants.ENDTIME;
-import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
-import static org.onap.so.logger.MdcConstants.PARTNERNAME;
-import static org.onap.so.logger.MdcConstants.RESPONSECODE;
-import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
-import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
-import static org.onap.so.logger.MdcConstants.STATUSCODE;
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -64,7 +56,6 @@ 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;
-import org.onap.so.logger.HttpHeadersConstants;
 import org.onap.so.serviceinstancebeans.CloudConfiguration;
 import org.onap.so.serviceinstancebeans.ModelInfo;
 import org.onap.so.serviceinstancebeans.ModelType;
@@ -89,12 +80,10 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.tomakehurst.wiremock.http.Fault;
-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;
@@ -116,12 +105,10 @@ 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");
-        headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
+        headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
         headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
         headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
         headers.set(CLIENT_ID, "VID");
@@ -132,7 +119,7 @@ public class ServiceInstancesTest extends BaseTest {
         } catch (MalformedURLException e) {
             e.printStackTrace();
         }
-        wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*")).willReturn(aResponse()
+        wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse()
                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
         Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
     }
@@ -225,35 +212,6 @@ public class ServiceInstancesTest extends BaseTest {
         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() != null && logEvent.getMarker().getName().equals("ENTRY")) {
-                Map<String, String> mdc = logEvent.getMDCPropertyMap();
-                assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
-                assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
-                assertNotNull(mdc.get(INVOCATION_ID));
-                assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
-                assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
-                assertEquals("INPROGRESS", mdc.get(STATUSCODE));
-            } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
-                    && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
-                Map<String, String> mdc = logEvent.getMDCPropertyMap();
-                assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
-                assertNotNull(mdc.get(ENDTIME));
-                assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
-                assertNotNull(mdc.get(INVOCATION_ID));
-                assertEquals("202", mdc.get(RESPONSECODE));
-                assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
-                assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
-                assertEquals("COMPLETE", mdc.get(STATUSCODE));
-                assertNotNull(mdc.get(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));
-            }
     }
 
     @Test
@@ -285,14 +243,13 @@ public class ServiceInstancesTest extends BaseTest {
         requestReferences.setInstanceId("1882939");
         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
         expectedResponse.setRequestReferences(requestReferences);
-        uri = servInstanceUriPrev7 + "v5";
+        uri = servInstanceuri + "v5";
         ResponseEntity<String> response =
                 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
 
         // then
-        assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
+        assertEquals(404, response.getStatusCode().value());
         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
-        assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
     }
 
     @Test
@@ -896,7 +853,7 @@ public class ServiceInstancesTest extends BaseTest {
         ResponseEntity<String> response =
                 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
 
-        assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+        assertEquals(404, response.getStatusCode().value());
     }
 
     @Test
@@ -905,7 +862,7 @@ public class ServiceInstancesTest extends BaseTest {
         ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
 
         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
     }
 
@@ -947,6 +904,45 @@ public class ServiceInstancesTest extends BaseTest {
         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
     }
 
+    @Test
+    public void replaceVnfInstanceNoCloudConfig() throws IOException {
+        wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/v1/getInfraActiveRequests.*"))
+                .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                        .withBodyFile("infra/VnfLookup.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+        wireMockServer.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)));
+        wireMockServer.stubFor(get(urlMatching(
+                ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
+                        .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withBody(getWiremockResponseForCatalogdb(
+                                        "vnfResourceCustomization_ReplaceVnf_Response.json"))
+                                .withStatus(org.apache.http.HttpStatus.SC_OK)));
+        wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
+                .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                        .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
+                        .withStatus(org.apache.http.HttpStatus.SC_OK)));
+        wireMockServer.stubFor(get(urlMatching(
+                ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
+                        .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_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-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+        ResponseEntity<String> response =
+                sendRequest(inputStream("/ReplaceVnfNoCloudConfig.json"), uri, HttpMethod.POST, 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 replaceVnfRecreateInstance() throws IOException {
         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
@@ -1338,7 +1334,7 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
     }
 
@@ -1378,6 +1374,44 @@ public class ServiceInstancesTest extends BaseTest {
         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
     }
 
+    @Test
+    public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException {
+        wireMockServer.stubFor(
+                get(urlPathEqualTo("/aai/v19/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000"))
+                        .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
+        wireMockServer.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)));
+        wireMockServer
+                .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
+                        + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
+                                .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                        .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
+                                        .withStatus(org.apache.http.HttpStatus.SC_OK)));
+        wireMockServer.stubFor(get(urlMatching(
+                ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
+                        + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
+                                .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+                                        .withBody(getWiremockResponseForCatalogdb(
+                                                "vnfComponentRecipeDeleteVfModule_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-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
+        ResponseEntity<String> response =
+                sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, 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 updateVfModuleInstance() throws IOException {
         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
@@ -1429,7 +1463,6 @@ public class ServiceInstancesTest extends BaseTest {
     public void createVfModuleNoModelType() throws IOException {
         InfraActiveRequests expectedRecord = new InfraActiveRequests();
         expectedRecord.setRequestStatus("FAILED");
-        expectedRecord.setAction("createInstance");
         expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
         expectedRecord.setProgress(100L);
         expectedRecord.setSource("VID");
@@ -2142,7 +2175,7 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
                 realResponse.getServiceException().getText());
     }
@@ -2177,7 +2210,7 @@ public class ServiceInstancesTest extends BaseTest {
                 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);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals("Exception caught mapping Camunda JSON response to object",
                 realResponse.getServiceException().getText());
     }
@@ -2210,7 +2243,7 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertTrue(realResponse.getServiceException().getText()
                 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
     }
@@ -2248,14 +2281,12 @@ public class ServiceInstancesTest extends BaseTest {
         requestReferences.setInstanceId("1882939");
         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
         expectedResponse.setRequestReferences(requestReferences);
-        uri = servInstanceUriPrev7 + "v5";
+        uri = servInstanceuri + "v5";
         ResponseEntity<String> response =
                 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
 
         // then
-        assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
-        ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
-        assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
+        assertEquals(404, response.getStatusCode().value());
     }
 
     @Test
@@ -2266,7 +2297,7 @@ public class ServiceInstancesTest extends BaseTest {
         RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
         String userParamsTxt = inputStream("/userParams.txt");
 
-        List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
+        List<Map<String, Object>> userParams = requestHandlerUtils.configureUserParams(requestParameters);
         System.out.println(userParams);
         assertTrue(userParams.size() > 0);
         assertTrue(userParams.get(0).containsKey("name"));
@@ -2280,7 +2311,7 @@ public class ServiceInstancesTest extends BaseTest {
         ServiceInstancesRequest request =
                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
         CloudConfiguration cloudConfig =
-                servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
+                requestHandlerUtils.configureCloudConfig(request.getRequestDetails().getRequestParameters());
 
         assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
         assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
@@ -2293,7 +2324,7 @@ public class ServiceInstancesTest extends BaseTest {
                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
         ServiceInstancesRequest expected =
                 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
-        servInstances.mapToLegacyRequest(request.getRequestDetails());
+        requestHandlerUtils.mapToLegacyRequest(request.getRequestDetails());
         System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
         assertThat(request, sameBeanAs(expected));
     }
@@ -2380,7 +2411,7 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals("Exception caught mapping Camunda JSON response to object",
                 realResponse.getServiceException().getText());
     }
@@ -2396,9 +2427,9 @@ public class ServiceInstancesTest extends BaseTest {
                 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);
+        RequestError realResponse = mapper.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",
+                "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
                 realResponse.getServiceException().getText());
     }
 
@@ -2419,7 +2450,7 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.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());
@@ -2441,9 +2472,9 @@ public class ServiceInstancesTest extends BaseTest {
                 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);
+        RequestError realResponse = mapper.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",
+                "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
                 realResponse.getServiceException().getText());
     }
 
@@ -2458,9 +2489,9 @@ public class ServiceInstancesTest extends BaseTest {
                 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);
+        RequestError realResponse = mapper.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",
+                "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
                 realResponse.getServiceException().getText());
     }
 
@@ -2490,9 +2521,9 @@ public class ServiceInstancesTest extends BaseTest {
                 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);
+        RequestError realResponse = mapper.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",
+                "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
                 realResponse.getServiceException().getText());
     }
 
@@ -2510,9 +2541,9 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.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",
+                "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
                 realResponse.getServiceException().getText());
     }
 
@@ -2527,9 +2558,9 @@ public class ServiceInstancesTest extends BaseTest {
                 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
 
         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.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",
+                "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
                 realResponse.getServiceException().getText());
     }
 
@@ -2572,15 +2603,6 @@ public class ServiceInstancesTest extends BaseTest {
         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
         assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
-
-        for (ILoggingEvent logEvent : TestAppender.events) {
-            if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging")
-                    && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
-                Map<String, String> mdc = logEvent.getMDCPropertyMap();
-                assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
-                assertEquals("VID", mdc.get(PARTNERNAME));
-            }
-        }
     }
 
     @Test
@@ -2632,7 +2654,7 @@ public class ServiceInstancesTest extends BaseTest {
         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
         // then
         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
     }
 
@@ -2645,7 +2667,7 @@ public class ServiceInstancesTest extends BaseTest {
         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
         // then
         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
     }
 
@@ -2664,7 +2686,7 @@ public class ServiceInstancesTest extends BaseTest {
 
         // then
         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
-        RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
     }
 
@@ -2752,7 +2774,7 @@ public class ServiceInstancesTest extends BaseTest {
         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);
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
         assertEquals(realResponse.getServiceException().getText(),
                 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
     }
@@ -2934,15 +2956,20 @@ public class ServiceInstancesTest extends BaseTest {
         Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
         assertEquals(Action.replaceInstanceRetainAssignments, action);
     }
-    /*
-     * @Test public void buildSelfLinkUrlTest() throws Exception { // v - version String incomingUrl =
-     * "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances"; String expectedSelfLink =
-     * "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1"; String requestId =
-     * "efce3167-5e45-4666-9d4d-22e23648e5d1"; Optional<URL> actualSelfLinkUrl = buildSelfLinkUrl(incomingUrl,
-     * requestId); assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString()); // V - Version String
-     * incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances"; String
-     * expectedSelfLinkV = "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1";
-     * Optional<URL> actualSelfLinkUrlV = buildSelfLinkUrl(incomingUrlV, requestId); assertEquals(expectedSelfLinkV,
-     * actualSelfLinkUrlV.get().toString()); }
-     */
+
+    @Test
+    public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
+        RequestError expectedResponse =
+                mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
+        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("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
+
+        assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
+        RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
+        assertThat(expectedResponse, sameBeanAs(realResponse));
+    }
+
 }
+