2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.so.apihandlerinfra;
 
  24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
 
  25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
 
  26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
 
  27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
 
  28 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
 
  29 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
 
  30 import static org.junit.Assert.assertEquals;
 
  31 import static org.junit.Assert.assertFalse;
 
  32 import static org.junit.Assert.assertNull;
 
  33 import static org.junit.Assert.assertThat;
 
  34 import static org.junit.Assert.assertTrue;
 
  35 import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_PARTNER_NAME;
 
  36 import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
 
  37 import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID;
 
  38 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
 
  40 import java.io.IOException;
 
  41 import java.net.MalformedURLException;
 
  43 import java.nio.file.Files;
 
  44 import java.nio.file.Paths;
 
  45 import java.util.List;
 
  47 import javax.ws.rs.core.MediaType;
 
  48 import javax.ws.rs.core.Response;
 
  49 import org.apache.http.HttpStatus;
 
  50 import org.junit.Before;
 
  51 import org.junit.Test;
 
  52 import org.mockito.Mockito;
 
  53 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 
  54 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
 
  55 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
 
  56 import org.onap.so.db.catalog.beans.Service;
 
  57 import org.onap.so.db.catalog.beans.ServiceRecipe;
 
  58 import org.onap.so.db.request.beans.InfraActiveRequests;
 
  59 import org.onap.so.serviceinstancebeans.CloudConfiguration;
 
  60 import org.onap.so.serviceinstancebeans.ModelInfo;
 
  61 import org.onap.so.serviceinstancebeans.ModelType;
 
  62 import org.onap.so.serviceinstancebeans.RequestDetails;
 
  63 import org.onap.so.serviceinstancebeans.RequestError;
 
  64 import org.onap.so.serviceinstancebeans.RequestInfo;
 
  65 import org.onap.so.serviceinstancebeans.RequestParameters;
 
  66 import org.onap.so.serviceinstancebeans.RequestReferences;
 
  67 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
 
  68 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
 
  69 import org.springframework.beans.factory.annotation.Autowired;
 
  70 import org.springframework.beans.factory.annotation.Value;
 
  71 import org.springframework.http.HttpEntity;
 
  72 import org.springframework.http.HttpHeaders;
 
  73 import org.springframework.http.HttpMethod;
 
  74 import org.springframework.http.ResponseEntity;
 
  75 import org.springframework.util.ResourceUtils;
 
  76 import org.springframework.web.util.UriComponentsBuilder;
 
  77 import com.fasterxml.jackson.core.JsonParseException;
 
  78 import com.fasterxml.jackson.core.JsonProcessingException;
 
  79 import com.fasterxml.jackson.databind.DeserializationFeature;
 
  80 import com.fasterxml.jackson.databind.JsonMappingException;
 
  81 import com.fasterxml.jackson.databind.ObjectMapper;
 
  82 import com.github.tomakehurst.wiremock.http.Fault;
 
  84 public class ServiceInstancesTest extends BaseTest {
 
  86     private final ObjectMapper mapper = new ObjectMapper();
 
  89     private ServiceInstances servInstances;
 
  92     private RequestHandlerUtils requestHandlerUtils;
 
  94     @Value("${wiremock.server.port}")
 
  95     private String wiremockPort;
 
  97     private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
 
  98     private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
 
 100     private URL selfLink;
 
 101     private URL initialUrl;
 
 102     private int initialPort;
 
 103     private HttpHeaders headers;
 
 106     public void beforeClass() {
 
 107         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 109         headers = new HttpHeaders();
 
 110         headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
 
 111         headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 112         headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 113         headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 114         headers.set(ONAP_PARTNER_NAME, "VID");
 
 115         headers.set(REQUESTOR_ID, "xxxxxx");
 
 116         try { // generate one-time port number to avoid RANDOM port number later.
 
 117             initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
 
 118             initialPort = initialUrl.getPort();
 
 119         } catch (MalformedURLException e) {
 
 122         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse()
 
 123                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
 
 124         Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
 
 127     public String inputStream(String JsonInput) throws IOException {
 
 128         JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
 
 129         return new String(Files.readAllBytes(Paths.get(JsonInput)));
 
 132     private URL createExpectedSelfLink(String version, String requestId) {
 
 133         System.out.println("createdUrl: " + initialUrl.toString());
 
 135             selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
 
 136         } catch (MalformedURLException e) {
 
 142     private String getWiremockResponseForCatalogdb(String file) {
 
 144             File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
 
 145             return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
 
 146                     "localhost:" + wiremockPort);
 
 147         } catch (IOException e) {
 
 154     public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
 
 155             HttpHeaders headers) {
 
 157         if (!headers.containsKey(HttpHeaders.ACCEPT)) {
 
 158             headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
 
 160         if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
 
 161             headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
 
 164         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
 
 166         HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
 
 168         return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
 
 171     public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
 
 172         return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
 
 176     public void createServiceInstanceVIDDefault() throws IOException {
 
 177         TestAppender.events.clear();
 
 179         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 180         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 181         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 182         serviceRecipe.setAction(Action.createInstance.toString());
 
 183         serviceRecipe.setId(1);
 
 184         serviceRecipe.setRecipeTimeout(180);
 
 185         Service defaultService = new Service();
 
 186         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 189         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 190                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 191                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 193         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 194                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 195                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 197         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 198                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 199                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 202         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 203         RequestReferences requestReferences = new RequestReferences();
 
 204         requestReferences.setInstanceId("1882939");
 
 205         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 206         expectedResponse.setRequestReferences(requestReferences);
 
 207         uri = servInstanceuri + "v5/serviceInstances";
 
 208         ResponseEntity<String> response =
 
 209                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
 212         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 213         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 214         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 218     public void createServiceInstanceServiceInstancesUri() throws IOException {
 
 219         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 220         serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
 
 221         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 222         serviceRecipe.setAction(Action.createInstance.toString());
 
 223         serviceRecipe.setId(1);
 
 224         serviceRecipe.setRecipeTimeout(180);
 
 225         Service defaultService = new Service();
 
 226         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 228         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
 
 229                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 230                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 233         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 234                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 235                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 237         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 238                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 239                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 241         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 242         RequestReferences requestReferences = new RequestReferences();
 
 243         requestReferences.setInstanceId("1882939");
 
 244         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 245         expectedResponse.setRequestReferences(requestReferences);
 
 246         uri = servInstanceuri + "v5";
 
 247         ResponseEntity<String> response =
 
 248                 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
 
 251         assertEquals(404, response.getStatusCode().value());
 
 252         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 256     public void createServiceInstanceBpelStatusError() throws IOException {
 
 257         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 258         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 259         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 260         serviceRecipe.setAction(Action.createInstance.toString());
 
 261         serviceRecipe.setId(1);
 
 262         serviceRecipe.setRecipeTimeout(180);
 
 263         Service defaultService = new Service();
 
 264         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 267         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
 268                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 269                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
 
 272         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 273                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 274                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 276         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 277                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 278                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 280         uri = servInstanceuri + "v5/serviceInstances";
 
 281         ResponseEntity<String> response =
 
 282                 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
 
 284         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
 288     public void createServiceInstanceBadGateway() throws IOException {
 
 289         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 290         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 291         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 292         serviceRecipe.setAction(Action.createInstance.toString());
 
 293         serviceRecipe.setId(1);
 
 294         serviceRecipe.setRecipeTimeout(180);
 
 295         Service defaultService = new Service();
 
 296         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 298         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 299                 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
 
 301         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 302                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 303                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 305         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 306                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 307                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 309         uri = servInstanceuri + "v5/serviceInstances";
 
 310         ResponseEntity<String> response =
 
 311                 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
 
 313         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
 317     public void createServiceInstanceEmptyResponse() throws IOException {
 
 318         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 319         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 320         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 321         serviceRecipe.setAction(Action.createInstance.toString());
 
 322         serviceRecipe.setId(1);
 
 323         serviceRecipe.setRecipeTimeout(180);
 
 324         Service defaultService = new Service();
 
 325         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 327         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 328                 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
 
 330         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 331                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 332                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 334         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 335                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 336                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 338         uri = servInstanceuri + "v5/serviceInstances";
 
 339         ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
 
 341         assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
 
 345     public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
 
 346         TestAppender.events.clear();
 
 347         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
 
 348         HttpHeaders requestIDheaders = new HttpHeaders();
 
 349         requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 350         ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
 
 351                 HttpMethod.POST, requestIDheaders);
 
 353         Service defaultService = new Service();
 
 354         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 356         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 357                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 358                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 361         wireMockServer.stubFor(get(urlMatching(
 
 362                 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
 
 363                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 364                                 .withStatus(HttpStatus.SC_NOT_FOUND)));
 
 366         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
 
 370     public void activateServiceInstanceNoRecipe() throws IOException {
 
 371         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
 
 372         Service defaultService = new Service();
 
 373         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 374         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 375                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 376                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 378         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
 
 379                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
 
 381         ResponseEntity<String> response =
 
 382                 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
 
 384         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
 
 388     public void activateServiceInstance() throws IOException {
 
 389         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 390         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 391         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 392         serviceRecipe.setAction(Action.createInstance.toString());
 
 393         serviceRecipe.setId(1);
 
 394         serviceRecipe.setRecipeTimeout(180);
 
 395         Service defaultService = new Service();
 
 396         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 398         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 399                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 400                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 402         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 403                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 404                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 406         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 407                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 408                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 410         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 411         RequestReferences requestReferences = new RequestReferences();
 
 412         requestReferences.setInstanceId("1882939");
 
 413         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 414         expectedResponse.setRequestReferences(requestReferences);
 
 415         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
 
 416         ResponseEntity<String> response =
 
 417                 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
 
 419         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 420         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 421         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 425     public void deactivateServiceInstance() throws IOException {
 
 427         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 428         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 429         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 430         serviceRecipe.setAction(Action.createInstance.toString());
 
 431         serviceRecipe.setId(1);
 
 432         serviceRecipe.setRecipeTimeout(180);
 
 433         Service defaultService = new Service();
 
 434         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 436         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 437                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 438                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 440         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 441                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 442                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 444         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 445                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 446                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 448         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 449                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 450                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 453         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 454         RequestReferences requestReferences = new RequestReferences();
 
 455         requestReferences.setInstanceId("1882939");
 
 456         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 457         expectedResponse.setRequestReferences(requestReferences);
 
 458         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
 
 459         ResponseEntity<String> response =
 
 460                 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
 
 462         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 463         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 464         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 468     public void deleteServiceInstance() throws IOException {
 
 469         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 470         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 471         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 472         serviceRecipe.setAction(Action.createInstance.toString());
 
 473         serviceRecipe.setId(1);
 
 474         serviceRecipe.setRecipeTimeout(180);
 
 475         Service defaultService = new Service();
 
 476         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 478         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 479                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 480                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 482         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 483                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 484                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 486         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 487                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 488                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 490         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 491                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 492                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 494         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 495         RequestReferences requestReferences = new RequestReferences();
 
 496         requestReferences.setInstanceId("1882939");
 
 497         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 498         expectedResponse.setRequestReferences(requestReferences);
 
 499         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
 
 500         ResponseEntity<String> response =
 
 501                 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
 
 503         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 504         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 505         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 509     public void assignServiceInstance() throws IOException {
 
 510         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 511         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 512         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 513         serviceRecipe.setAction(Action.createInstance.toString());
 
 514         serviceRecipe.setId(1);
 
 515         serviceRecipe.setRecipeTimeout(180);
 
 516         Service defaultService = new Service();
 
 517         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 519         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 520                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 521                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 523         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 524                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 525                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 527         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 528                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 529                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 531         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 532                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 533                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 535         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 536         RequestReferences requestReferences = new RequestReferences();
 
 537         requestReferences.setInstanceId("1882939");
 
 538         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 539         expectedResponse.setRequestReferences(requestReferences);
 
 540         uri = servInstanceuri + "v7" + "/serviceInstances/assign";
 
 541         ResponseEntity<String> response =
 
 542                 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
 
 544         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 545         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 546         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 550     public void unassignServiceInstance() throws IOException {
 
 551         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 552         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 553         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 554         serviceRecipe.setAction(Action.createInstance.toString());
 
 555         serviceRecipe.setId(1);
 
 556         serviceRecipe.setRecipeTimeout(180);
 
 557         Service defaultService = new Service();
 
 558         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 560         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 561                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 562                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 564         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 565                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 566                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 568         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 569                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 570                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 572         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 573                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 574                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 576         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 577         RequestReferences requestReferences = new RequestReferences();
 
 578         requestReferences.setInstanceId("1882939");
 
 579         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 580         expectedResponse.setRequestReferences(requestReferences);
 
 581         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
 
 582         ResponseEntity<String> response =
 
 583                 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
 
 585         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 586         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 587         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 591     public void createPortConfiguration() throws IOException {
 
 592         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 593                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 594                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 596         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 597         RequestReferences requestReferences = new RequestReferences();
 
 598         requestReferences.setInstanceId("1882939");
 
 599         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 600         expectedResponse.setRequestReferences(requestReferences);
 
 601         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
 602         ResponseEntity<String> response =
 
 603                 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
 
 605         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 606         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 607         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 608         assertTrue(response.getBody().contains("1882939"));
 
 612     public void createPortConfigurationEmptyProductFamilyId() throws IOException {
 
 613         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
 614         ResponseEntity<String> response =
 
 615                 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
 
 617         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
 621     public void deletePortConfiguration() throws IOException {
 
 622         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 623                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 624                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 627         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 628         RequestReferences requestReferences = new RequestReferences();
 
 629         requestReferences.setInstanceId("1882939");
 
 630         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 631         expectedResponse.setRequestReferences(requestReferences);
 
 632         uri = servInstanceuri + "v7"
 
 633                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
 
 634         ResponseEntity<String> response =
 
 635                 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
 
 637         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 638         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 639         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 643     public void enablePort() throws IOException {
 
 644         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 645                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 646                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 648         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 649         RequestReferences requestReferences = new RequestReferences();
 
 650         requestReferences.setInstanceId("1882939");
 
 651         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 652         expectedResponse.setRequestReferences(requestReferences);
 
 653         uri = servInstanceuri + "v7"
 
 654                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
 
 655         ResponseEntity<String> response =
 
 656                 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
 
 658         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 659         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 660         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 664     public void disablePort() throws IOException {
 
 665         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 666                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 667                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 669         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 670         RequestReferences requestReferences = new RequestReferences();
 
 671         requestReferences.setInstanceId("1882939");
 
 672         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 673         expectedResponse.setRequestReferences(requestReferences);
 
 674         uri = servInstanceuri + "v7"
 
 675                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
 
 676         ResponseEntity<String> response =
 
 677                 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
 
 679         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 680         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 681         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 685     public void activatePort() throws IOException {
 
 686         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 687                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 688                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 690         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 691         RequestReferences requestReferences = new RequestReferences();
 
 692         requestReferences.setInstanceId("1882939");
 
 693         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 694         expectedResponse.setRequestReferences(requestReferences);
 
 695         uri = servInstanceuri + "v7"
 
 696                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
 
 697         ResponseEntity<String> response =
 
 698                 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
 
 700         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 701         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 702         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 706     public void deactivatePort() throws IOException {
 
 707         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 708                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 709                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 711         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 712         RequestReferences requestReferences = new RequestReferences();
 
 713         requestReferences.setInstanceId("1882939");
 
 714         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 715         expectedResponse.setRequestReferences(requestReferences);
 
 716         uri = servInstanceuri + "v7"
 
 717                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
 
 718         ResponseEntity<String> response =
 
 719                 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
 
 721         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 722         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 723         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 727     public void addRelationships() throws IOException {
 
 728         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 729                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 730                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 732         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 733         RequestReferences requestReferences = new RequestReferences();
 
 734         requestReferences.setInstanceId("1882939");
 
 735         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 736         expectedResponse.setRequestReferences(requestReferences);
 
 737         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
 
 738         ResponseEntity<String> response =
 
 739                 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
 
 741         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 742         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 743         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 747     public void removeRelationships() throws IOException {
 
 748         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 749                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 750                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 752         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 753         RequestReferences requestReferences = new RequestReferences();
 
 754         requestReferences.setInstanceId("1882939");
 
 755         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 756         expectedResponse.setRequestReferences(requestReferences);
 
 757         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
 
 758         ResponseEntity<String> response =
 
 759                 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
 
 761         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 762         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 763         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 767     public void createVnfInstanceNoALaCarte() throws IOException {
 
 768         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 769                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 770                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 773         wireMockServer.stubFor(get(urlMatching(
 
 774                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
 
 775                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 776                                 .withBody(getWiremockResponseForCatalogdb(
 
 777                                         "vnfResourceCustomization_ReplaceVnf_Response.json"))
 
 778                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 780         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
 
 781                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 782                         .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
 
 783                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 785         wireMockServer.stubFor(get(urlMatching(
 
 786                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
 
 787                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 788                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
 
 789                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 792         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 793         RequestReferences requestReferences = new RequestReferences();
 
 794         requestReferences.setInstanceId("1882939");
 
 795         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 796         expectedResponse.setRequestReferences(requestReferences);
 
 797         uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
 
 798         ResponseEntity<String> response =
 
 799                 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
 
 801         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 802         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 803         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 807     public void createVnfInstance() throws IOException {
 
 808         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 809                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 810                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 812         wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
 
 813                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 814                         .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
 
 815                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 816         wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
 
 817                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 818                         .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
 
 819                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 822         wireMockServer.stubFor(
 
 823                 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
 
 824                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 825                                 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
 
 826                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 828         wireMockServer.stubFor(get(urlMatching(
 
 829                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
 
 830                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 831                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
 
 832                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 835         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 836         RequestReferences requestReferences = new RequestReferences();
 
 837         requestReferences.setInstanceId("1882939");
 
 838         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 839         expectedResponse.setRequestReferences(requestReferences);
 
 840         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
 
 841         ResponseEntity<String> response =
 
 842                 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
 
 844         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 845         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 846         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 847         assertTrue(response.getBody().contains("1882939"));
 
 851     public void createVnfWithServiceRelatedInstanceFail() throws IOException {
 
 852         uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
 
 853         ResponseEntity<String> response =
 
 854                 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
 
 856         assertEquals(404, response.getStatusCode().value());
 
 860     public void createVnfInstanceInvalidVnfResource() throws IOException {
 
 861         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
 
 862         ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
 
 864         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
 865         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
 866         assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
 
 870     public void replaceVnfInstance() throws IOException {
 
 871         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 872                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 873                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 875         wireMockServer.stubFor(get(urlMatching(
 
 876                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
 
 877                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 878                                 .withBody(getWiremockResponseForCatalogdb(
 
 879                                         "vnfResourceCustomization_ReplaceVnf_Response.json"))
 
 880                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 882         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
 
 883                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 884                         .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
 
 885                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 887         wireMockServer.stubFor(get(urlMatching(
 
 888                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
 
 889                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 890                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
 
 891                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 893         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 894         RequestReferences requestReferences = new RequestReferences();
 
 895         requestReferences.setInstanceId("1882939");
 
 896         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 897         expectedResponse.setRequestReferences(requestReferences);
 
 898         uri = servInstanceuri + "v7"
 
 899                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
 900         ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
 
 902         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 903         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 904         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 908     public void replaceVnfInstanceNoCloudConfig() throws IOException {
 
 909         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/v1/getInfraActiveRequests.*"))
 
 910                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 911                         .withBodyFile("infra/VnfLookup.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 912         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 913                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 914                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 915         wireMockServer.stubFor(get(urlMatching(
 
 916                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
 
 917                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 918                                 .withBody(getWiremockResponseForCatalogdb(
 
 919                                         "vnfResourceCustomization_ReplaceVnf_Response.json"))
 
 920                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 921         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
 
 922                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 923                         .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
 
 924                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 925         wireMockServer.stubFor(get(urlMatching(
 
 926                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
 
 927                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 928                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
 
 929                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 931         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 932         RequestReferences requestReferences = new RequestReferences();
 
 933         requestReferences.setInstanceId("1882939");
 
 934         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 935         expectedResponse.setRequestReferences(requestReferences);
 
 936         uri = servInstanceuri + "v7"
 
 937                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
 938         ResponseEntity<String> response =
 
 939                 sendRequest(inputStream("/ReplaceVnfNoCloudConfig.json"), uri, HttpMethod.POST, headers);
 
 941         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 942         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 943         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 947     public void replaceVnfRecreateInstance() throws IOException {
 
 948         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
 
 949                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 950                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 952         wireMockServer.stubFor(get(urlMatching(
 
 953                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
 
 954                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 955                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
 
 956                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 958         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
 959                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 960                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
 961                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 963         wireMockServer.stubFor(get(urlMatching(
 
 964                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
 
 965                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 966                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
 
 967                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 970         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 971         RequestReferences requestReferences = new RequestReferences();
 
 972         requestReferences.setInstanceId("1882939");
 
 973         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 974         expectedResponse.setRequestReferences(requestReferences);
 
 975         uri = servInstanceuri + "v7"
 
 976                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
 977         ResponseEntity<String> response =
 
 978                 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
 
 979         logger.debug(response.getBody());
 
 981         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 982         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 983         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 987     public void recreateVnfInstance() throws IOException {
 
 988         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 989                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 990                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 992         wireMockServer.stubFor(get(urlMatching(
 
 993                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
 
 994                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 995                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
 
 996                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 998         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
 999                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1000                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
1001                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1003         wireMockServer.stubFor(get(urlMatching(
 
1004                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
 
1005                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1006                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
 
1007                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1009         // expected response
 
1010         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1011         RequestReferences requestReferences = new RequestReferences();
 
1012         requestReferences.setInstanceId("1882939");
 
1013         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1014         expectedResponse.setRequestReferences(requestReferences);
 
1015         uri = servInstanceuri + "v7"
 
1016                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
 
1017         ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
 
1018         logger.debug(response.getBody());
 
1020         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1021         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1022         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1026     public void updateVnfInstance() throws IOException {
 
1027         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1028                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1029                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1031         wireMockServer.stubFor(get(urlMatching(
 
1032                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
 
1033                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1034                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
 
1035                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1037         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
1038                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1039                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
1040                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1042         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
1043                 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
 
1044                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1045                                 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
 
1046                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1048         // expected response
 
1049         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1050         RequestReferences requestReferences = new RequestReferences();
 
1051         requestReferences.setInstanceId("1882939");
 
1052         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1053         expectedResponse.setRequestReferences(requestReferences);
 
1054         uri = servInstanceuri + "v7"
 
1055                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1056         ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
 
1058         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1059         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1060         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1064     public void applyUpdatedConfig() throws IOException {
 
1065         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
 
1066                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1067                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1070         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
1071                 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
 
1072                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1073                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
 
1074                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1076         // expected response
 
1077         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1078         RequestReferences requestReferences = new RequestReferences();
 
1079         requestReferences.setInstanceId("1882939");
 
1080         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1081         expectedResponse.setRequestReferences(requestReferences);
 
1082         uri = servInstanceuri + "v7"
 
1083                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
 
1084         ResponseEntity<String> response =
 
1085                 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
 
1087         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1088         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1089         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1093     public void deleteVnfInstanceV5() throws IOException {
 
1094         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1095                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1096                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1098         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
1099                 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
 
1100                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1101                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
 
1102                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1103         // expected response
 
1104         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1105         RequestReferences requestReferences = new RequestReferences();
 
1106         requestReferences.setInstanceId("1882939");
 
1107         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1108         expectedResponse.setRequestReferences(requestReferences);
 
1109         uri = servInstanceuri + "v5"
 
1110                 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
 
1111         ResponseEntity<String> response =
 
1112                 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
 
1114         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1115         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1116         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1120     public void createVfModuleInstance() throws IOException {
 
1121         wireMockServer.stubFor(get(urlMatching(
 
1122                 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
 
1123                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1124                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
 
1125                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1127         wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
 
1128                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1129                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1130                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1132         wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
 
1133                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1134                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1135                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1137         wireMockServer.stubFor(get(urlMatching(
 
1138                 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
 
1139                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1140                                 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1141                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1143         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
 
1144                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1145                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1147         wireMockServer.stubFor(get(urlMatching(
 
1148                 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1149                         + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
 
1150                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1151                                         .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
 
1152                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1153         // expected response
 
1154         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1155         RequestReferences requestReferences = new RequestReferences();
 
1156         requestReferences.setInstanceId("1882939");
 
1157         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1158         expectedResponse.setRequestReferences(requestReferences);
 
1159         uri = servInstanceuri + "v7"
 
1160                 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
 
1161         ResponseEntity<String> response =
 
1162                 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
 
1164         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1165         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1166         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1167         assertTrue(response.getBody().contains("1882939"));
 
1171     public void createVfModuleInstanceNoModelCustomization() throws IOException {
 
1172         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
 
1173                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1174                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1176         wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1177                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1178                         .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
 
1179                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1182                 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
 
1183                         + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1184                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1185                                         .withBody(getWiremockResponseForCatalogdb(
 
1186                                                 "vnfResourceCustomizationForVfModule_Response.json"))
 
1187                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1189         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
 
1190                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1191                         .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
 
1192                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1194         wireMockServer.stubFor(get(urlMatching(
 
1195                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
 
1196                         + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
 
1197                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1198                                         .withBody(getWiremockResponseForCatalogdb(
 
1199                                                 "vfModuleCustomizationPCM_Response.json"))
 
1200                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1202         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
 
1203                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1204                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1205                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1207         wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
 
1208                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1209                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1210                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1213         wireMockServer.stubFor(
 
1214                 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
 
1215                         + "[?]vnfComponentType=vfModule&action=createInstance"))
 
1216                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1217                                         .withBody(getWiremockResponseForCatalogdb(
 
1218                                                 "vnfComponentRecipeVNF_API_Response.json"))
 
1219                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1221         // expected response
 
1222         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1223         RequestReferences requestReferences = new RequestReferences();
 
1224         requestReferences.setInstanceId("1882939");
 
1225         requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1226         expectedResponse.setRequestReferences(requestReferences);
 
1227         uri = servInstanceuri + "v6"
 
1228                 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
 
1229         ResponseEntity<String> response =
 
1230                 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
 
1231         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1232         ObjectMapper mapper = new ObjectMapper();
 
1233         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1234         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1238     public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
 
1239         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1240                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1241                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1243         wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
 
1244                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1245                         .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
 
1246                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1249                 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
 
1250                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1251                                 .withBody(getWiremockResponseForCatalogdb(
 
1252                                         "vnfResourceCustomizationForVfModule_Response.json"))
 
1253                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1255         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
 
1256                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1257                         .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
 
1258                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1260         wireMockServer.stubFor(get(urlMatching(
 
1261                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
 
1262                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1263                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
 
1264                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1266         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
 
1267                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1268                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1269                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1271         wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
 
1272                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1273                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1274                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1276         wireMockServer.stubFor(get(urlMatching(
 
1277                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1278                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
 
1279                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1280                                         .withBody(getWiremockResponseForCatalogdb(
 
1281                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1282                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1284         // expected response
 
1285         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1286         RequestReferences requestReferences = new RequestReferences();
 
1287         requestReferences.setInstanceId("1882939");
 
1288         requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1289         expectedResponse.setRequestReferences(requestReferences);
 
1290         uri = servInstanceuri + "v6"
 
1291                 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1292         ResponseEntity<String> response =
 
1293                 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
 
1296         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1297         ObjectMapper mapper = new ObjectMapper();
 
1298         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1299         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1303     public void createVfModuleInstanceNoRecipe() throws IOException {
 
1305         wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1306                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1307                         .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
 
1308                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1311                 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
 
1312                         + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1313                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1314                                         .withBody(getWiremockResponseForCatalogdb(
 
1315                                                 "vnfResourceCustomizationForVfModule_Response.json"))
 
1316                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1318         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
 
1319                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1320                         .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
 
1321                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1323         wireMockServer.stubFor(
 
1324                 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
 
1325                         + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
 
1326                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1327                                         .withBody(getWiremockResponseForCatalogdb(
 
1328                                                 "vfModuleCustomizationPCM_Response.json"))
 
1329                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1331         uri = servInstanceuri + "v6"
 
1332                 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
 
1333         ResponseEntity<String> response =
 
1334                 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
 
1336         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1337         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
1338         assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
 
1342     public void replaceVfModuleInstance() throws IOException {
 
1343         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1344                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1345                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1348                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1349                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1350                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1351                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1352                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1354         wireMockServer.stubFor(get(urlMatching(
 
1355                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1356                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
 
1357                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1358                                         .withBody(getWiremockResponseForCatalogdb(
 
1359                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1360                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1361         // expected response
 
1362         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1363         RequestReferences requestReferences = new RequestReferences();
 
1364         requestReferences.setInstanceId("1882939");
 
1365         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1366         expectedResponse.setRequestReferences(requestReferences);
 
1367         uri = servInstanceuri + "v7"
 
1368                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
1369         ResponseEntity<String> response =
 
1370                 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
 
1372         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1373         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1374         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1378     public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException {
 
1379         wireMockServer.stubFor(
 
1380                 get(urlPathEqualTo("/aai/v19/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000"))
 
1381                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1382                                 .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1383         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1384                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1385                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1387                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1388                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1389                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1390                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1391                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1392         wireMockServer.stubFor(get(urlMatching(
 
1393                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1394                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
 
1395                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1396                                         .withBody(getWiremockResponseForCatalogdb(
 
1397                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1398                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1399         // expected response
 
1400         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1401         RequestReferences requestReferences = new RequestReferences();
 
1402         requestReferences.setInstanceId("1882939");
 
1403         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1404         expectedResponse.setRequestReferences(requestReferences);
 
1405         uri = servInstanceuri + "v7"
 
1406                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
1407         ResponseEntity<String> response =
 
1408                 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
 
1410         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1411         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1412         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1416     public void updateVfModuleInstance() throws IOException {
 
1417         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1418                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1419                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1421         wireMockServer.stubFor(get(urlMatching(
 
1422                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
 
1423                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1424                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
 
1425                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1427         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1428                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1429                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1430                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1432         wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
 
1433                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1434                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1435                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1437         wireMockServer.stubFor(get(urlMatching(
 
1438                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1439                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
 
1440                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1441                                         .withBody(getWiremockResponseForCatalogdb(
 
1442                                                 "vnfComponentRecipe_GRAPI_Response.json"))
 
1443                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1445         // expected response
 
1446         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1447         RequestReferences requestReferences = new RequestReferences();
 
1448         requestReferences.setInstanceId("1882939");
 
1449         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1450         expectedResponse.setRequestReferences(requestReferences);
 
1451         uri = servInstanceuri + "v7"
 
1452                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1453         ResponseEntity<String> response =
 
1454                 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
 
1455         logger.debug(response.getBody());
 
1457         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1458         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1459         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1463     public void createVfModuleNoModelType() throws IOException {
 
1464         InfraActiveRequests expectedRecord = new InfraActiveRequests();
 
1465         expectedRecord.setRequestStatus("FAILED");
 
1466         expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
 
1467         expectedRecord.setProgress(100L);
 
1468         expectedRecord.setSource("VID");
 
1469         expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
 
1470         expectedRecord.setLastModifiedBy("APIH");
 
1471         expectedRecord.setVfModuleName("testVfModule2");
 
1472         expectedRecord.setVfModuleModelName("serviceModel");
 
1473         expectedRecord.setRequestScope("vfModule");
 
1474         expectedRecord.setRequestAction("createInstance");
 
1475         expectedRecord.setRequestorId("zz9999");
 
1476         expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
 
1477         // VnfType is not sent in this request, should be blank in db
 
1478         expectedRecord.setVnfType("");
 
1479         uri = servInstanceuri
 
1480                 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
 
1482         ResponseEntity<String> response =
 
1483                 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
 
1485         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1489     public void inPlaceSoftwareUpdate() throws IOException {
 
1490         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
 
1491                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1492                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1494         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
 
1495                 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
 
1496                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1497                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
 
1498                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1500         // expected response
 
1501         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1502         RequestReferences requestReferences = new RequestReferences();
 
1503         requestReferences.setInstanceId("1882939");
 
1504         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1505         expectedResponse.setRequestReferences(requestReferences);
 
1506         uri = servInstanceuri + "v7"
 
1507                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
 
1508         ResponseEntity<String> response =
 
1509                 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
 
1511         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1512         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1513         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1517     public void deleteVfModuleInstance() throws IOException {
 
1518         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1519                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1520                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1523                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1524                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1525                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1526                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1527                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1529         wireMockServer.stubFor(get(urlMatching(
 
1530                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1531                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
 
1532                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1533                                         .withBody(getWiremockResponseForCatalogdb(
 
1534                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1535                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1537         // expected response
 
1538         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1539         RequestReferences requestReferences = new RequestReferences();
 
1540         requestReferences.setInstanceId("1882939");
 
1541         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1542         expectedResponse.setRequestReferences(requestReferences);
 
1543         uri = servInstanceuri + "v7"
 
1544                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1545         ResponseEntity<String> response =
 
1546                 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
 
1548         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1549         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1550         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1554     public void deleteVfModuleNoModelInvariantId() throws IOException {
 
1555         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1556                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1557                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1559         wireMockServer.stubFor(get(urlMatching(
 
1560                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1561                         + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
 
1562                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1563                                         .withBody(getWiremockResponseForCatalogdb(
 
1564                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1565                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1567         // expected response
 
1568         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1569         RequestReferences requestReferences = new RequestReferences();
 
1570         requestReferences.setInstanceId("1882939");
 
1571         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1572         expectedResponse.setRequestReferences(requestReferences);
 
1573         uri = servInstanceuri + "v7"
 
1574                 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
 
1575         ResponseEntity<String> response =
 
1576                 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
 
1578         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1579         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1580         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1584     public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
 
1585         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1586                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1587                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1590                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1591                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1592                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1593                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1594                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1596         wireMockServer.stubFor(get(urlMatching(
 
1597                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1598                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
 
1599                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1600                                         .withBody(getWiremockResponseForCatalogdb(
 
1601                                                 "vnfComponentRecipeDeactivate_Response.json"))
 
1602                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1604         // expected response
 
1605         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1606         RequestReferences requestReferences = new RequestReferences();
 
1607         requestReferences.setInstanceId("1882939");
 
1608         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1609         expectedResponse.setRequestReferences(requestReferences);
 
1610         uri = servInstanceuri + "v7"
 
1611                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
 
1612         ResponseEntity<String> response =
 
1613                 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
 
1615         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1616         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1617         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1621     public void createVolumeGroupInstance() throws IOException {
 
1622         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1623                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1624                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1626         wireMockServer.stubFor(get(urlMatching(
 
1627                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
 
1628                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1629                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
 
1630                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1632         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1633                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1634                         .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
 
1635                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1637         wireMockServer.stubFor(get(urlMatching(
 
1638                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1639                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
 
1640                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1641                                         .withBody(getWiremockResponseForCatalogdb(
 
1642                                                 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
 
1643                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1645         // expected response
 
1646         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1647         RequestReferences requestReferences = new RequestReferences();
 
1648         requestReferences.setInstanceId("1882939");
 
1649         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1650         expectedResponse.setRequestReferences(requestReferences);
 
1651         uri = servInstanceuri + "v7"
 
1652                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
 
1653         ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
 
1655         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1656         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1657         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1658         assertTrue(response.getBody().contains("1882939"));
 
1662     public void updateVolumeGroupInstance() throws IOException {
 
1663         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1664                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1665                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1667         wireMockServer.stubFor(get(urlMatching(
 
1668                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
 
1669                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1670                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
 
1671                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1673         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1674                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1675                         .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
 
1676                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1678         wireMockServer.stubFor(get(urlMatching(
 
1679                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1680                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
 
1681                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1682                                         .withBody(getWiremockResponseForCatalogdb(
 
1683                                                 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
 
1684                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1686         // expected response
 
1687         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1688         RequestReferences requestReferences = new RequestReferences();
 
1689         requestReferences.setInstanceId("1882939");
 
1690         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1691         expectedResponse.setRequestReferences(requestReferences);
 
1692         uri = servInstanceuri + "v7"
 
1693                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1694         ResponseEntity<String> response =
 
1695                 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
 
1697         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1698         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1699         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1703     public void deleteVolumeGroupInstance() throws IOException {
 
1704         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1705                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1706                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1708         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1709                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1710                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1712         wireMockServer.stubFor(get(urlMatching(
 
1713                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
 
1714                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1715                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
 
1716                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1718         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1719                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1720                         .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
 
1721                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1723         wireMockServer.stubFor(get(urlMatching(
 
1724                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1725                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
 
1726                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1727                                         .withBody(getWiremockResponseForCatalogdb(
 
1728                                                 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
 
1729                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1731         // expected response
 
1732         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1733         RequestReferences requestReferences = new RequestReferences();
 
1734         requestReferences.setInstanceId("1882939");
 
1735         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1736         expectedResponse.setRequestReferences(requestReferences);
 
1737         uri = servInstanceuri + "v7"
 
1738                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1739         ResponseEntity<String> response =
 
1740                 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
 
1742         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1743         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1744         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1748     public void createNetworkInstance() throws IOException {
 
1749         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1750                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1751                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1753         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1754                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1755                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1756                         .withStatus(HttpStatus.SC_OK)));
 
1758         wireMockServer.stubFor(
 
1759                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1760                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1761                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1762                                 .withStatus(HttpStatus.SC_OK)));
 
1764         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1765                 + "modelName=GR-API-DEFAULT&action=createInstance"))
 
1766                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1767                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1768                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1770         // expected response
 
1771         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1772         RequestReferences requestReferences = new RequestReferences();
 
1773         requestReferences.setInstanceId("1882939");
 
1774         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1775         expectedResponse.setRequestReferences(requestReferences);
 
1776         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
1777         ResponseEntity<String> response =
 
1778                 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
 
1780         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1781         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1782         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1786     public void updateNetworkInstance() throws IOException {
 
1787         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1788                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1789                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1791         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1792                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1793                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1794                         .withStatus(HttpStatus.SC_OK)));
 
1796         wireMockServer.stubFor(
 
1797                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1798                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1799                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1800                                 .withStatus(HttpStatus.SC_OK)));
 
1802         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1803                 + "modelName=GR-API-DEFAULT&action=updateInstance"))
 
1804                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1805                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1806                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1807         // expected response
 
1808         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1809         RequestReferences requestReferences = new RequestReferences();
 
1810         requestReferences.setInstanceId("1882939");
 
1811         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1812         expectedResponse.setRequestReferences(requestReferences);
 
1813         uri = servInstanceuri + "v7"
 
1814                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1815         ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
 
1817         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1818         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1819         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1820         assertTrue(response.getBody().contains("1882939"));
 
1824     public void deleteNetworkInstance() throws IOException {
 
1825         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1826                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1827                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1829         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1830                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1831                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1832                         .withStatus(HttpStatus.SC_OK)));
 
1834         wireMockServer.stubFor(
 
1835                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1836                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1837                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1838                                 .withStatus(HttpStatus.SC_OK)));
 
1840         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1841                 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
 
1842                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1843                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1844                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1846         // expected response
 
1847         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1848         RequestReferences requestReferences = new RequestReferences();
 
1849         requestReferences.setInstanceId("1882939");
 
1850         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1851         expectedResponse.setRequestReferences(requestReferences);
 
1852         uri = servInstanceuri + "v7"
 
1853                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1854         ResponseEntity<String> response =
 
1855                 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
 
1857         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1858         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1859         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1863     public void deleteNetworkInstanceNoReqParams() throws IOException {
 
1864         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1865                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1866                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1868         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1869                 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
 
1870                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1871                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1872                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1875         // expected response
 
1876         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1877         RequestReferences requestReferences = new RequestReferences();
 
1878         requestReferences.setInstanceId("1882939");
 
1879         requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1880         expectedResponse.setRequestReferences(requestReferences);
 
1881         uri = servInstanceuri + "v6"
 
1882                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1883         ResponseEntity<String> response =
 
1884                 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
 
1886         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1887         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1888         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1892     public void convertJsonToServiceInstanceRequestFail() throws IOException {
 
1894         InfraActiveRequests expectedRecord = new InfraActiveRequests();
 
1895         expectedRecord.setRequestStatus("FAILED");
 
1896         expectedRecord.setStatusMessage("Error mapping request: ");
 
1897         expectedRecord.setProgress(100L);
 
1898         expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
 
1899         expectedRecord.setLastModifiedBy("APIH");
 
1900         expectedRecord.setRequestScope("network");
 
1901         expectedRecord.setRequestAction("deleteInstance");
 
1902         expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
 
1904         uri = servInstanceuri + "v6"
 
1905                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1906         ResponseEntity<String> response =
 
1907                 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
 
1911         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1915     public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
 
1916         uri = servInstanceuri + "v5"
 
1917                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
 
1918         ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
 
1920         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1924     public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
 
1925         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1926                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1927                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1929         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
1930         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
1931         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
1932         serviceRecipe.setAction(Action.createInstance.toString());
 
1933         serviceRecipe.setId(1);
 
1934         serviceRecipe.setRecipeTimeout(180);
 
1935         Service defaultService = new Service();
 
1936         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
1938         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
1939                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1940                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
1942         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
1943                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1944                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
1946         uri = servInstanceuri + "v7" + "/serviceInstances";
 
1947         ResponseEntity<String> response =
 
1948                 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
 
1950         // expected response
 
1951         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1952         RequestReferences requestReferences = new RequestReferences();
 
1953         requestReferences.setInstanceId("1882939");
 
1954         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1955         expectedResponse.setRequestReferences(requestReferences);
 
1957         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1958         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1959         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1963     public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
 
1964         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1965                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1966                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1968         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1969                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1970                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1971                         .withStatus(HttpStatus.SC_OK)));
 
1973         wireMockServer.stubFor(
 
1974                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1975                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1976                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1977                                 .withStatus(HttpStatus.SC_OK)));
 
1979         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1980                 + "modelName=GR-API-DEFAULT&action=createInstance"))
 
1981                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1982                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1983                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1985         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
1986         ResponseEntity<String> response =
 
1987                 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
 
1989         // expected response
 
1990         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1991         RequestReferences requestReferences = new RequestReferences();
 
1992         requestReferences.setInstanceId("1882939");
 
1993         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1994         expectedResponse.setRequestReferences(requestReferences);
 
1996         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1997         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1998         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2002     public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
 
2003         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2004                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2005                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2007         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2008         ResponseEntity<String> response =
 
2009                 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
 
2011         // expected response
 
2012         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2013         RequestReferences requestReferences = new RequestReferences();
 
2014         requestReferences.setInstanceId("1882939");
 
2015         expectedResponse.setRequestReferences(requestReferences);
 
2017         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2021     public void createNetworkInstanceTestApiGrApi() throws IOException {
 
2022         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2023                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2024                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2026         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2027                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2028                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
2029                         .withStatus(HttpStatus.SC_OK)));
 
2031         wireMockServer.stubFor(
 
2032                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
2033                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2034                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
2035                                 .withStatus(HttpStatus.SC_OK)));
 
2037         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2038                 + "modelName=GR-API-DEFAULT&action=createInstance"))
 
2039                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2040                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
2041                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2043         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2044         ResponseEntity<String> response =
 
2045                 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
 
2047         // expected response
 
2048         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2049         RequestReferences requestReferences = new RequestReferences();
 
2050         requestReferences.setInstanceId("1882939");
 
2051         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2052         expectedResponse.setRequestReferences(requestReferences);
 
2054         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2055         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2056         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2060     public void createNetworkInstanceTestApiVnfApi() throws IOException {
 
2061         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
 
2062                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2063                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2065         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2066                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2067                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
2068                         .withStatus(HttpStatus.SC_OK)));
 
2070         wireMockServer.stubFor(
 
2071                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
2072                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2073                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
2074                                 .withStatus(HttpStatus.SC_OK)));
 
2076         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2077                 + "modelName=VNF-API-DEFAULT&action=createInstance"))
 
2078                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2079                                 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
 
2080                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2082         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2083         ResponseEntity<String> response =
 
2084                 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
 
2086         // expected response
 
2087         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2088         RequestReferences requestReferences = new RequestReferences();
 
2089         requestReferences.setInstanceId("1882939");
 
2090         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2091         expectedResponse.setRequestReferences(requestReferences);
 
2093         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2094         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2095         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2099     public void activateServiceInstanceRequestStatus() throws IOException {
 
2100         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2101         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2102         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2103         serviceRecipe.setAction(Action.createInstance.toString());
 
2104         serviceRecipe.setId(1);
 
2105         serviceRecipe.setRecipeTimeout(180);
 
2106         Service defaultService = new Service();
 
2107         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2109         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2110                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2111                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2113         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2114                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2115                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2117         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2118                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2119                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2122         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2123         RequestReferences requestReferences = new RequestReferences();
 
2124         requestReferences.setInstanceId("1882939");
 
2125         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2126         expectedResponse.setRequestReferences(requestReferences);
 
2127         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
 
2128         ResponseEntity<String> response =
 
2129                 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
 
2131         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2132         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2133         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2137     public void invalidRequestId() throws IOException {
 
2138         String illegalRequestId = "1234";
 
2139         HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
 
2140         ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
 
2141         uri = servInstanceuri + "v5/serviceInstances";
 
2142         ResponseEntity<String> response =
 
2143                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
 
2145         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2146         assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
 
2150     public void invalidBPELResponse() throws IOException {
 
2152         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2153         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2154         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2155         serviceRecipe.setAction(Action.createInstance.toString());
 
2156         serviceRecipe.setId(1);
 
2157         serviceRecipe.setRecipeTimeout(180);
 
2158         Service defaultService = new Service();
 
2159         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2161         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
2162                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2163                 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2165         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2166                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2167                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2169         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2170                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2171                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2173         uri = servInstanceuri + "v5/serviceInstances";
 
2174         ResponseEntity<String> response =
 
2175                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2177         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2178         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2179         assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
 
2180                 realResponse.getServiceException().getText());
 
2184     public void unauthorizedBPELResponse() throws IOException {
 
2186         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2187         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2188         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2189         serviceRecipe.setAction(Action.createInstance.toString());
 
2190         serviceRecipe.setId(1);
 
2191         serviceRecipe.setRecipeTimeout(180);
 
2192         Service defaultService = new Service();
 
2193         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2195         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2196                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2197                         .withBodyFile("Camunda/UnauthorizedResponse.json")
 
2198                         .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
 
2200         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2201                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2202                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2204         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2205                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2206                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2208         uri = servInstanceuri + "v5/serviceInstances";
 
2209         ResponseEntity<String> response =
 
2210                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2212         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2213         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2214         assertEquals("Exception caught mapping Camunda JSON response to object",
 
2215                 realResponse.getServiceException().getText());
 
2219     public void invalidBPELResponse2() throws IOException {
 
2221         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2222         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2223         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2224         serviceRecipe.setAction(Action.createInstance.toString());
 
2225         serviceRecipe.setId(1);
 
2226         serviceRecipe.setRecipeTimeout(180);
 
2227         Service defaultService = new Service();
 
2228         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2230         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
2231                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2232                 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2234         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2235                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2236                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2238         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2239                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2240                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2241         uri = servInstanceuri + "v5/serviceInstances";
 
2242         ResponseEntity<String> response =
 
2243                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2245         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2246         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2247         assertTrue(realResponse.getServiceException().getText()
 
2248                 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
 
2252     public void createMacroServiceInstance() throws IOException {
 
2253         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2254         serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
 
2255         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2256         serviceRecipe.setAction(Action.createInstance.toString());
 
2257         serviceRecipe.setId(1);
 
2258         serviceRecipe.setRecipeTimeout(180);
 
2259         Service defaultService = new Service();
 
2260         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2262         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
 
2263                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2264                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2266         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
2267                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2268                 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2270         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2271                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2272                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2274         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2275                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2276                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2279         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2280         RequestReferences requestReferences = new RequestReferences();
 
2281         requestReferences.setInstanceId("1882939");
 
2282         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2283         expectedResponse.setRequestReferences(requestReferences);
 
2284         uri = servInstanceuri + "v5";
 
2285         ResponseEntity<String> response =
 
2286                 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
 
2289         assertEquals(404, response.getStatusCode().value());
 
2293     public void testUserParams() throws IOException {
 
2294         ObjectMapper mapper = new ObjectMapper();
 
2295         ServiceInstancesRequest request =
 
2296                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2297         RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
 
2298         String userParamsTxt = inputStream("/userParams.txt");
 
2300         List<Map<String, Object>> userParams = requestHandlerUtils.configureUserParams(requestParameters);
 
2301         System.out.println(userParams);
 
2302         assertTrue(userParams.size() > 0);
 
2303         assertTrue(userParams.get(0).containsKey("name"));
 
2304         assertTrue(userParams.get(0).containsKey("value"));
 
2305         assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
 
2309     public void testConfigureCloudConfig() throws IOException {
 
2310         ObjectMapper mapper = new ObjectMapper();
 
2311         ServiceInstancesRequest request =
 
2312                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2313         CloudConfiguration cloudConfig =
 
2314                 requestHandlerUtils.configureCloudConfig(request.getRequestDetails().getRequestParameters());
 
2316         assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
 
2317         assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
 
2321     public void testMapToLegacyRequest() throws IOException {
 
2322         ObjectMapper mapper = new ObjectMapper();
 
2323         ServiceInstancesRequest request =
 
2324                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2325         ServiceInstancesRequest expected =
 
2326                 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2327         requestHandlerUtils.mapToLegacyRequest(request.getRequestDetails());
 
2328         System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
 
2329         assertThat(request, sameBeanAs(expected));
 
2333     public void scaleOutVfModule() throws IOException {
 
2334         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2335                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2336                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2338         wireMockServer.stubFor(get(urlMatching(
 
2339                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
 
2340                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2341                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
 
2342                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2344         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
2345                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2346                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
2347                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2349         wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
 
2350                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2351                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
2352                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2355         wireMockServer.stubFor(get(urlMatching(
 
2356                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
2357                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
 
2358                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2359                                         .withBody(getWiremockResponseForCatalogdb(
 
2360                                                 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
 
2361                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2363         wireMockServer.stubFor(get(urlMatching(
 
2364                 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
 
2365                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2366                                 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
 
2367                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2369         // expected response
 
2370         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2371         RequestReferences requestReferences = new RequestReferences();
 
2372         requestReferences.setInstanceId("1882939");
 
2373         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2374         expectedResponse.setRequestReferences(requestReferences);
 
2375         uri = servInstanceuri + "v7"
 
2376                 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
 
2377         ResponseEntity<String> response =
 
2378                 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
 
2380         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2381         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2382         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2383         assertTrue(response.getBody().contains("1882939"));
 
2387     public void createServiceInstanceBadResponse() throws IOException {
 
2388         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2389         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2390         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2391         serviceRecipe.setAction(Action.createInstance.toString());
 
2392         serviceRecipe.setId(1);
 
2393         serviceRecipe.setRecipeTimeout(180);
 
2394         Service defaultService = new Service();
 
2395         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2397         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2398                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2399                         .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2401         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2402                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2403                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2405         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2406                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2407                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2409         uri = servInstanceuri + "v5/serviceInstances";
 
2410         ResponseEntity<String> response =
 
2411                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2413         assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
 
2414         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2415         assertEquals("Exception caught mapping Camunda JSON response to object",
 
2416                 realResponse.getServiceException().getText());
 
2420     public void createServiceInstanceDuplicateError() throws IOException {
 
2421         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2422                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2423                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2425         uri = servInstanceuri + "v5/serviceInstances";
 
2426         ResponseEntity<String> response =
 
2427                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2429         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2430         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2432                 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
 
2433                 realResponse.getServiceException().getText());
 
2437     public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
 
2438         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2439                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2440                         .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
 
2441                         .withStatus(HttpStatus.SC_ACCEPTED)));
 
2442         wireMockServer.stubFor(get(
 
2443                 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
 
2444                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2445                                 .withBodyFile("Camunda/HistoryCheckResponse.json")
 
2446                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2448         uri = servInstanceuri + "v5/serviceInstances";
 
2449         ResponseEntity<String> response =
 
2450                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2452         assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
 
2453         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2455                 "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.",
 
2456                 realResponse.getServiceException().getText());
 
2460     public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
 
2461         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2462                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2463                         .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
 
2464                         .withStatus(HttpStatus.SC_ACCEPTED)));
 
2465         wireMockServer.stubFor(get(
 
2466                 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
 
2467                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2468                                 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2470         uri = servInstanceuri + "v5/serviceInstances";
 
2471         ResponseEntity<String> response =
 
2472                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2474         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2475         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2477                 "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",
 
2478                 realResponse.getServiceException().getText());
 
2482     public void createServiceInstanceDuplicate() throws IOException {
 
2483         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2484                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2485                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2487         uri = servInstanceuri + "v5/serviceInstances";
 
2488         ResponseEntity<String> response =
 
2489                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2491         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2492         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2494                 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
 
2495                 realResponse.getServiceException().getText());
 
2499     public void createServiceInstanceSaveError() throws IOException {
 
2500         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2501         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2502         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2503         serviceRecipe.setAction(Action.createInstance.toString());
 
2504         serviceRecipe.setId(1);
 
2505         serviceRecipe.setRecipeTimeout(180);
 
2506         Service defaultService = new Service();
 
2507         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2508         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
 
2509                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2510                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2511         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2512                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2513                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2515         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2516                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2517                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2519         uri = servInstanceuri + "v5/serviceInstances";
 
2520         ResponseEntity<String> response =
 
2521                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2523         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2524         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2526                 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
 
2527                 realResponse.getServiceException().getText());
 
2531     public void createPortConfigurationSaveError() throws IOException {
 
2532         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
 
2533                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2534                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2535         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
2536                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2537                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2539         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
2540         ResponseEntity<String> response =
 
2541                 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
 
2543         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2544         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2546                 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
 
2547                 realResponse.getServiceException().getText());
 
2551     public void createPortConfigDbUpdateError() throws IOException {
 
2552         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
 
2553                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2554                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2556         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
2557         ResponseEntity<String> response =
 
2558                 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
 
2560         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2561         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2563                 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
 
2564                 realResponse.getServiceException().getText());
 
2568     public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
 
2569         TestAppender.events.clear();
 
2570         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2571                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2572                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2574         wireMockServer.stubFor(get(urlMatching(
 
2575                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
 
2576                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2577                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
 
2578                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2580         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
2581                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2582                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
2583                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2585         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
2586                 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
 
2587                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2588                                 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
 
2589                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2590         headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
 
2592         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2593         RequestReferences requestReferences = new RequestReferences();
 
2594         requestReferences.setInstanceId("1882939");
 
2595         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2596         expectedResponse.setRequestReferences(requestReferences);
 
2597         uri = servInstanceuri
 
2598                 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
 
2599         ResponseEntity<String> response =
 
2600                 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
 
2602         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2603         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2604         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2605         assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
2609     public void createInstanceGroup() throws IOException {
 
2610         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2611                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2612                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2615         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2616         RequestReferences requestReferences = new RequestReferences();
 
2617         requestReferences.setInstanceId("1882939");
 
2618         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2619         expectedResponse.setRequestReferences(requestReferences);
 
2620         uri = servInstanceuri + "/v7/instanceGroups";
 
2621         ResponseEntity<String> response =
 
2622                 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
 
2625         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2626         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2627         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2631     public void deleteInstanceGroup() throws IOException {
 
2632         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2633                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2634                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2637         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2638         RequestReferences requestReferences = new RequestReferences();
 
2639         requestReferences.setInstanceId("1882939");
 
2640         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2641         expectedResponse.setRequestReferences(requestReferences);
 
2642         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2643         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
 
2646         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2647         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2648         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2652     public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
 
2653         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2654         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
 
2656         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2657         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2658         assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
 
2662     public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
 
2663         HttpHeaders noPartnerHeaders = new HttpHeaders();
 
2664         noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
 
2665         noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
 
2666         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2667         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
 
2669         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2670         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2671         assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
 
2675     public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
 
2676         HttpHeaders noRequestorIdHheaders = new HttpHeaders();
 
2677         noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
 
2678         noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
 
2680         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2681         RequestReferences requestReferences = new RequestReferences();
 
2682         requestReferences.setInstanceId("1882939");
 
2683         expectedResponse.setRequestReferences(requestReferences);
 
2684         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2685         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
 
2688         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2689         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2690         assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
 
2694     public void addMembers() throws IOException {
 
2695         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2696                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2697                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2699         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2700         RequestReferences requestReferences = new RequestReferences();
 
2701         requestReferences.setInstanceId("1882939");
 
2702         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2703         expectedResponse.setRequestReferences(requestReferences);
 
2704         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
 
2705         ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
 
2708         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2709         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2710         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2714     public void removeMembers() throws IOException {
 
2715         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2716                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2717                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2719         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2720         RequestReferences requestReferences = new RequestReferences();
 
2721         requestReferences.setInstanceId("1882939");
 
2722         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2723         expectedResponse.setRequestReferences(requestReferences);
 
2724         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
 
2725         ResponseEntity<String> response =
 
2726                 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
 
2729         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2730         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2731         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2735     public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
 
2736         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2737                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2738                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2740         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2741                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2742                         .withStatus(HttpStatus.SC_NOT_FOUND)));
 
2744         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2745                 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
 
2746                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2747                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
2748                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2750         // expected response
 
2751         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2752         RequestReferences requestReferences = new RequestReferences();
 
2753         requestReferences.setInstanceId("1882939");
 
2754         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2755         expectedResponse.setRequestReferences(requestReferences);
 
2756         uri = servInstanceuri + "v7"
 
2757                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
2758         ResponseEntity<String> response =
 
2759                 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
 
2761         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2762         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2763         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2767     public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
 
2768         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2769                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2770                         .withStatus(HttpStatus.SC_NOT_FOUND)));
 
2772         uri = servInstanceuri + "v7"
 
2773                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
2774         ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
 
2776         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2777         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2778         assertEquals(realResponse.getServiceException().getText(),
 
2779                 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
 
2783     public void setServiceTypeTestALaCarte() throws JsonProcessingException {
 
2784         String requestScope = ModelType.service.toString();
 
2785         Boolean aLaCarteFlag = true;
 
2786         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2787         RequestDetails requestDetails = new RequestDetails();
 
2788         RequestInfo requestInfo = new RequestInfo();
 
2789         requestInfo.setSource("VID");
 
2790         requestDetails.setRequestInfo(requestInfo);
 
2791         sir.setRequestDetails(requestDetails);
 
2792         Service defaultService = new Service();
 
2793         defaultService.setServiceType("testServiceTypeALaCarte");
 
2795         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
2796                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2797                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2799         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2800         assertEquals(serviceType, "testServiceTypeALaCarte");
 
2804     public void setServiceTypeTest() throws JsonProcessingException {
 
2805         String requestScope = ModelType.service.toString();
 
2806         Boolean aLaCarteFlag = false;
 
2807         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2808         RequestDetails requestDetails = new RequestDetails();
 
2809         RequestInfo requestInfo = new RequestInfo();
 
2810         ModelInfo modelInfo = new ModelInfo();
 
2811         modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
 
2812         requestInfo.setSource("VID");
 
2813         requestDetails.setModelInfo(modelInfo);
 
2814         requestDetails.setRequestInfo(requestInfo);
 
2815         sir.setRequestDetails(requestDetails);
 
2816         Service defaultService = new Service();
 
2817         defaultService.setServiceType("testServiceType");
 
2819         wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
 
2820                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2821                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2823         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2824         assertEquals(serviceType, "testServiceType");
 
2828     public void setServiceTypeTestDefault() throws JsonProcessingException {
 
2829         String requestScope = ModelType.service.toString();
 
2830         Boolean aLaCarteFlag = false;
 
2831         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2832         RequestDetails requestDetails = new RequestDetails();
 
2833         RequestInfo requestInfo = new RequestInfo();
 
2834         ModelInfo modelInfo = new ModelInfo();
 
2835         modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
 
2836         requestInfo.setSource("VID");
 
2837         requestDetails.setModelInfo(modelInfo);
 
2838         requestDetails.setRequestInfo(requestInfo);
 
2839         sir.setRequestDetails(requestDetails);
 
2840         Service defaultService = new Service();
 
2841         defaultService.setServiceType("testServiceType");
 
2843         wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
 
2844                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2845                         .withStatus(HttpStatus.SC_NOT_FOUND)));
 
2846         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
2847                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2848                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2850         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2851         assertEquals(serviceType, "testServiceType");
 
2855     public void setServiceTypeTestNetwork() throws JsonProcessingException {
 
2856         String requestScope = ModelType.network.toString();
 
2857         Boolean aLaCarteFlag = null;
 
2858         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2859         RequestDetails requestDetails = new RequestDetails();
 
2860         RequestInfo requestInfo = new RequestInfo();
 
2861         ModelInfo modelInfo = new ModelInfo();
 
2862         modelInfo.setModelName("networkModelName");
 
2863         requestInfo.setSource("VID");
 
2864         requestDetails.setModelInfo(modelInfo);
 
2865         requestDetails.setRequestInfo(requestInfo);
 
2866         sir.setRequestDetails(requestDetails);
 
2868         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2869         assertEquals(serviceType, "networkModelName");
 
2873     public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
 
2874         String requestScope = "instanceGroup";
 
2875         ServiceInstancesRequest sir =
 
2876                 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
 
2877         assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
 
2878                 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
 
2882     public void setServiceInstanceIdTest() {
 
2883         String requestScope = "vnf";
 
2884         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2885         sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2886         assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
 
2887                 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
 
2891     public void setServiceInstanceIdReturnNullTest() {
 
2892         String requestScope = "vnf";
 
2893         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2894         assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
 
2898     public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
 
2899         wireMockServer.stubFor(get(
 
2900                 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
 
2901                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2902                                 .withBodyFile("Camunda/HistoryCheckResponse.json")
 
2903                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2905         InfraActiveRequests duplicateRecord = new InfraActiveRequests();
 
2906         duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2907         boolean inProgress = false;
 
2908         inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
 
2909         assertTrue(inProgress);
 
2913     public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
 
2914         wireMockServer.stubFor(get(
 
2915                 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
 
2916                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2917                                 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2919         InfraActiveRequests duplicateRecord = new InfraActiveRequests();
 
2920         duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2921         boolean inProgress = false;
 
2922         inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
 
2923         assertFalse(inProgress);
 
2927     public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException {
 
2928         wireMockServer.stubFor(get(
 
2929                 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
 
2930                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2931                                 .withBodyFile("Camunda/HistoryCheckResponseCompleted.json")
 
2932                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2934         InfraActiveRequests duplicateRecord = new InfraActiveRequests();
 
2935         duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2936         boolean inProgress = false;
 
2937         inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
 
2938         assertFalse(inProgress);
 
2942     public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
 
2943         String replaceVfModule = inputStream("/ReplaceVfModule.json");
 
2944         ObjectMapper mapper = new ObjectMapper();
 
2945         ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
 
2946         Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
 
2947         assertEquals(Action.replaceInstance, action);
 
2951     public void handleReplaceInstance_retainAssignments_Test()
 
2952             throws JsonParseException, JsonMappingException, IOException {
 
2953         String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
 
2954         ObjectMapper mapper = new ObjectMapper();
 
2955         ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
 
2956         Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
 
2957         assertEquals(Action.replaceInstanceRetainAssignments, action);
 
2961     public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
 
2962         RequestError expectedResponse =
 
2963                 mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
 
2964         uri = servInstanceuri + "v7"
 
2965                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
2966         ResponseEntity<String> response =
 
2967                 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
 
2969         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2970         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2971         assertThat(expectedResponse, sameBeanAs(realResponse));