2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2020 Nordix Foundation.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  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.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
 
  30 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
 
  31 import static org.junit.Assert.assertEquals;
 
  32 import static org.junit.Assert.assertFalse;
 
  33 import static org.junit.Assert.assertNull;
 
  34 import static org.junit.Assert.assertThat;
 
  35 import static org.junit.Assert.assertTrue;
 
  36 import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_PARTNER_NAME;
 
  37 import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
 
  38 import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID;
 
  39 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
 
  41 import java.io.IOException;
 
  42 import java.net.MalformedURLException;
 
  44 import java.nio.file.Files;
 
  45 import java.nio.file.Paths;
 
  46 import java.util.List;
 
  48 import javax.ws.rs.core.MediaType;
 
  49 import javax.ws.rs.core.Response;
 
  50 import org.apache.http.HttpStatus;
 
  51 import org.junit.Before;
 
  52 import org.junit.Test;
 
  53 import org.mockito.Mockito;
 
  54 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 
  55 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
 
  56 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
 
  57 import org.onap.so.db.catalog.beans.Service;
 
  58 import org.onap.so.db.catalog.beans.ServiceRecipe;
 
  59 import org.onap.so.db.request.beans.InfraActiveRequests;
 
  60 import org.onap.so.serviceinstancebeans.CloudConfiguration;
 
  61 import org.onap.so.serviceinstancebeans.ModelInfo;
 
  62 import org.onap.so.serviceinstancebeans.ModelType;
 
  63 import org.onap.so.serviceinstancebeans.RequestDetails;
 
  64 import org.onap.so.serviceinstancebeans.RequestError;
 
  65 import org.onap.so.serviceinstancebeans.RequestInfo;
 
  66 import org.onap.so.serviceinstancebeans.RequestParameters;
 
  67 import org.onap.so.serviceinstancebeans.RequestReferences;
 
  68 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
 
  69 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
 
  70 import org.springframework.beans.factory.annotation.Autowired;
 
  71 import org.springframework.beans.factory.annotation.Value;
 
  72 import org.springframework.http.HttpEntity;
 
  73 import org.springframework.http.HttpHeaders;
 
  74 import org.springframework.http.HttpMethod;
 
  75 import org.springframework.http.ResponseEntity;
 
  76 import org.springframework.util.ResourceUtils;
 
  77 import org.springframework.web.util.UriComponentsBuilder;
 
  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/";
 
  99     private final String orchestration_path = "/onap/so/infra";
 
 102     private URL selfLink;
 
 103     private URL initialUrl;
 
 104     private int initialPort;
 
 105     private HttpHeaders headers;
 
 108     public void beforeClass() {
 
 109         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 111         headers = new HttpHeaders();
 
 112         headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
 
 113         headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 114         headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 115         headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 116         headers.set(ONAP_PARTNER_NAME, "VID");
 
 117         headers.set(REQUESTOR_ID, "xxxxxx");
 
 118         try { // generate one-time port number to avoid RANDOM port number later.
 
 119             initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH, orchestration_path));
 
 120             initialPort = initialUrl.getPort();
 
 121         } catch (MalformedURLException e) {
 
 124         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse()
 
 125                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
 
 126         Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
 
 129     public String inputStream(String JsonInput) throws IOException {
 
 130         JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
 
 131         return new String(Files.readAllBytes(Paths.get(JsonInput)));
 
 134     private URL createExpectedSelfLink(String version, String requestId) {
 
 135         System.out.println("createdUrl: " + initialUrl.toString());
 
 137             selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
 
 138         } catch (MalformedURLException e) {
 
 144     private String getWiremockResponseForCatalogdb(String file) {
 
 146             File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
 
 147             return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
 
 148                     "localhost:" + wiremockPort);
 
 149         } catch (IOException e) {
 
 156     public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
 
 157             HttpHeaders headers) {
 
 159         if (!headers.containsKey(HttpHeaders.ACCEPT)) {
 
 160             headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
 
 162         if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
 
 163             headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
 
 166         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
 
 168         HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
 
 170         return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
 
 173     public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
 
 174         return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
 
 178     public void createServiceInstanceVIDDefault() throws IOException {
 
 179         TestAppender.events.clear();
 
 181         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 182         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 183         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 184         serviceRecipe.setAction(Action.createInstance.toString());
 
 185         serviceRecipe.setId(1);
 
 186         serviceRecipe.setRecipeTimeout(180);
 
 187         Service defaultService = new Service();
 
 188         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 191         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 192                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 193                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 195         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 196                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 197                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 199         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 200                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 201                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 204         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 205         RequestReferences requestReferences = new RequestReferences();
 
 206         requestReferences.setInstanceId("1882939");
 
 207         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 208         expectedResponse.setRequestReferences(requestReferences);
 
 209         uri = servInstanceuri + "v5/serviceInstances";
 
 210         ResponseEntity<String> response =
 
 211                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
 214         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 215         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 216         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 220     public void createServiceInstanceServiceInstancesUri() throws IOException {
 
 221         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 222         serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
 
 223         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 224         serviceRecipe.setAction(Action.createInstance.toString());
 
 225         serviceRecipe.setId(1);
 
 226         serviceRecipe.setRecipeTimeout(180);
 
 227         Service defaultService = new Service();
 
 228         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 230         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
 
 231                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 232                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 235         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 236                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 237                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 239         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 240                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 241                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 243         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 244         RequestReferences requestReferences = new RequestReferences();
 
 245         requestReferences.setInstanceId("1882939");
 
 246         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 247         expectedResponse.setRequestReferences(requestReferences);
 
 248         uri = servInstanceuri + "v5";
 
 249         ResponseEntity<String> response =
 
 250                 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
 
 253         assertEquals(404, response.getStatusCode().value());
 
 254         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 258     public void createServiceInstanceBpelStatusError() throws IOException {
 
 259         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 260         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 261         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 262         serviceRecipe.setAction(Action.createInstance.toString());
 
 263         serviceRecipe.setId(1);
 
 264         serviceRecipe.setRecipeTimeout(180);
 
 265         Service defaultService = new Service();
 
 266         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 269         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
 270                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 271                 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
 
 274         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 275                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 276                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 278         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 279                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 280                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 282         uri = servInstanceuri + "v5/serviceInstances";
 
 283         ResponseEntity<String> response =
 
 284                 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
 
 286         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
 290     public void createServiceInstanceBadGateway() throws IOException {
 
 291         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 292         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 293         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 294         serviceRecipe.setAction(Action.createInstance.toString());
 
 295         serviceRecipe.setId(1);
 
 296         serviceRecipe.setRecipeTimeout(180);
 
 297         Service defaultService = new Service();
 
 298         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 300         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 301                 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
 
 303         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 304                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 305                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 307         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 308                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 309                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 311         uri = servInstanceuri + "v5/serviceInstances";
 
 312         ResponseEntity<String> response =
 
 313                 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
 
 315         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
 319     public void createServiceInstanceEmptyResponse() throws IOException {
 
 320         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 321         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 322         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 323         serviceRecipe.setAction(Action.createInstance.toString());
 
 324         serviceRecipe.setId(1);
 
 325         serviceRecipe.setRecipeTimeout(180);
 
 326         Service defaultService = new Service();
 
 327         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 329         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 330                 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
 
 332         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 333                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 334                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 336         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 337                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 338                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 340         uri = servInstanceuri + "v5/serviceInstances";
 
 341         ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
 
 343         assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
 
 347     public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
 
 348         TestAppender.events.clear();
 
 349         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
 
 350         HttpHeaders requestIDheaders = new HttpHeaders();
 
 351         requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
 352         ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
 
 353                 HttpMethod.POST, requestIDheaders);
 
 355         Service defaultService = new Service();
 
 356         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 358         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 359                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 360                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 363         wireMockServer.stubFor(get(urlMatching(
 
 364                 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
 
 365                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 366                                 .withStatus(HttpStatus.SC_NOT_FOUND)));
 
 368         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
 
 372     public void activateServiceInstanceNoRecipe() throws IOException {
 
 373         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
 
 374         Service defaultService = new Service();
 
 375         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 376         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 377                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 378                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 380         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
 
 381                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
 
 383         ResponseEntity<String> response =
 
 384                 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
 
 386         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
 
 390     public void activateServiceInstance() throws IOException {
 
 391         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 392         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 393         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 394         serviceRecipe.setAction(Action.createInstance.toString());
 
 395         serviceRecipe.setId(1);
 
 396         serviceRecipe.setRecipeTimeout(180);
 
 397         Service defaultService = new Service();
 
 398         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 400         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 401                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 402                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 404         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 405                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 406                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 408         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 409                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 410                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 412         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 413         RequestReferences requestReferences = new RequestReferences();
 
 414         requestReferences.setInstanceId("1882939");
 
 415         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 416         expectedResponse.setRequestReferences(requestReferences);
 
 417         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
 
 418         ResponseEntity<String> response =
 
 419                 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
 
 421         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 422         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 423         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 427     public void deactivateServiceInstance() throws IOException {
 
 429         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 430         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 431         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 432         serviceRecipe.setAction(Action.createInstance.toString());
 
 433         serviceRecipe.setId(1);
 
 434         serviceRecipe.setRecipeTimeout(180);
 
 435         Service defaultService = new Service();
 
 436         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 438         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 439                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 440                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 442         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 443                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 444                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 446         wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
 
 447                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 448                         .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
 
 450         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 451                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 452                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 454         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 455                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 456                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 459         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 460         RequestReferences requestReferences = new RequestReferences();
 
 461         requestReferences.setInstanceId("1882939");
 
 462         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 463         expectedResponse.setRequestReferences(requestReferences);
 
 464         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
 
 465         ResponseEntity<String> response =
 
 466                 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
 
 468         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 469         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 470         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 474     public void deleteServiceInstance() throws IOException {
 
 475         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 476         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 477         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 478         serviceRecipe.setAction(Action.createInstance.toString());
 
 479         serviceRecipe.setId(1);
 
 480         serviceRecipe.setRecipeTimeout(180);
 
 481         Service defaultService = new Service();
 
 482         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 484         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 485                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 486                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 488         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 489                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 490                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 492         wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
 
 493                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 494                         .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
 
 496         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 497                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 498                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 500         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 501                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 502                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 504         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 505         RequestReferences requestReferences = new RequestReferences();
 
 506         requestReferences.setInstanceId("1882939");
 
 507         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 508         expectedResponse.setRequestReferences(requestReferences);
 
 509         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
 
 510         ResponseEntity<String> response =
 
 511                 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
 
 513         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 514         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 515         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 519     public void assignServiceInstance() throws IOException {
 
 520         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 521         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 522         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 523         serviceRecipe.setAction(Action.createInstance.toString());
 
 524         serviceRecipe.setId(1);
 
 525         serviceRecipe.setRecipeTimeout(180);
 
 526         Service defaultService = new Service();
 
 527         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 529         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 530                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 531                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 533         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 534                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 535                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 537         wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
 
 538                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 539                         .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
 
 541         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 542                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 543                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 545         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 546                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 547                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 549         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 550         RequestReferences requestReferences = new RequestReferences();
 
 551         requestReferences.setInstanceId("1882939");
 
 552         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 553         expectedResponse.setRequestReferences(requestReferences);
 
 554         uri = servInstanceuri + "v7" + "/serviceInstances/assign";
 
 555         ResponseEntity<String> response =
 
 556                 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
 
 558         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 559         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 560         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 564     public void unassignServiceInstance() throws IOException {
 
 565         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
 566         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
 567         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 568         serviceRecipe.setAction(Action.createInstance.toString());
 
 569         serviceRecipe.setId(1);
 
 570         serviceRecipe.setRecipeTimeout(180);
 
 571         Service defaultService = new Service();
 
 572         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
 574         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 575                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 576                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 578         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
 579                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 580                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 582         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
 583                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 584                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
 586         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
 587                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 588                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
 590         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 591         RequestReferences requestReferences = new RequestReferences();
 
 592         requestReferences.setInstanceId("1882939");
 
 593         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 594         expectedResponse.setRequestReferences(requestReferences);
 
 595         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
 
 596         ResponseEntity<String> response =
 
 597                 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
 
 599         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 600         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 601         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 605     public void createPortConfiguration() throws IOException {
 
 606         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 607                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 608                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 610         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 611         RequestReferences requestReferences = new RequestReferences();
 
 612         requestReferences.setInstanceId("1882939");
 
 613         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 614         expectedResponse.setRequestReferences(requestReferences);
 
 615         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
 616         ResponseEntity<String> response =
 
 617                 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
 
 619         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 620         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 621         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 622         assertTrue(response.getBody().contains("1882939"));
 
 626     public void createPortConfigurationEmptyProductFamilyId() throws IOException {
 
 627         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
 628         ResponseEntity<String> response =
 
 629                 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
 
 631         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
 635     public void deletePortConfiguration() throws IOException {
 
 636         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 637                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 638                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 641         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 642         RequestReferences requestReferences = new RequestReferences();
 
 643         requestReferences.setInstanceId("1882939");
 
 644         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 645         expectedResponse.setRequestReferences(requestReferences);
 
 646         uri = servInstanceuri + "v7"
 
 647                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
 
 648         ResponseEntity<String> response =
 
 649                 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
 
 651         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 652         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 653         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 657     public void enablePort() throws IOException {
 
 658         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 659                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 660                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 662         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 663         RequestReferences requestReferences = new RequestReferences();
 
 664         requestReferences.setInstanceId("1882939");
 
 665         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 666         expectedResponse.setRequestReferences(requestReferences);
 
 667         uri = servInstanceuri + "v7"
 
 668                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
 
 669         ResponseEntity<String> response =
 
 670                 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
 
 672         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 673         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 674         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 678     public void disablePort() throws IOException {
 
 679         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 680                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 681                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 683         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 684         RequestReferences requestReferences = new RequestReferences();
 
 685         requestReferences.setInstanceId("1882939");
 
 686         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 687         expectedResponse.setRequestReferences(requestReferences);
 
 688         uri = servInstanceuri + "v7"
 
 689                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
 
 690         ResponseEntity<String> response =
 
 691                 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
 
 693         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 694         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 695         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 699     public void activatePort() throws IOException {
 
 700         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 701                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 702                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 704         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 705         RequestReferences requestReferences = new RequestReferences();
 
 706         requestReferences.setInstanceId("1882939");
 
 707         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 708         expectedResponse.setRequestReferences(requestReferences);
 
 709         uri = servInstanceuri + "v7"
 
 710                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
 
 711         ResponseEntity<String> response =
 
 712                 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
 
 714         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 715         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 716         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 720     public void deactivatePort() throws IOException {
 
 721         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 722                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 723                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 725         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 726         RequestReferences requestReferences = new RequestReferences();
 
 727         requestReferences.setInstanceId("1882939");
 
 728         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 729         expectedResponse.setRequestReferences(requestReferences);
 
 730         uri = servInstanceuri + "v7"
 
 731                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
 
 732         ResponseEntity<String> response =
 
 733                 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
 
 735         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 736         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 737         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 741     public void addRelationships() throws IOException {
 
 742         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 743                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 744                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 746         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 747         RequestReferences requestReferences = new RequestReferences();
 
 748         requestReferences.setInstanceId("1882939");
 
 749         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 750         expectedResponse.setRequestReferences(requestReferences);
 
 751         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
 
 752         ResponseEntity<String> response =
 
 753                 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
 
 755         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 756         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 757         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 761     public void removeRelationships() throws IOException {
 
 762         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
 763                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 764                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 766         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 767         RequestReferences requestReferences = new RequestReferences();
 
 768         requestReferences.setInstanceId("1882939");
 
 769         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 770         expectedResponse.setRequestReferences(requestReferences);
 
 771         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
 
 772         ResponseEntity<String> response =
 
 773                 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
 
 775         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 776         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 777         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 781     public void createVnfInstanceNoALaCarte() throws IOException {
 
 782         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 783                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 784                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 787         wireMockServer.stubFor(get(urlMatching(
 
 788                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
 
 789                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 790                                 .withBody(getWiremockResponseForCatalogdb(
 
 791                                         "vnfResourceCustomization_ReplaceVnf_Response.json"))
 
 792                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 794         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
 
 795                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 796                         .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
 
 797                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 799         wireMockServer.stubFor(get(urlMatching(
 
 800                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
 
 801                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 802                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
 
 803                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 806         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 807         RequestReferences requestReferences = new RequestReferences();
 
 808         requestReferences.setInstanceId("1882939");
 
 809         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 810         expectedResponse.setRequestReferences(requestReferences);
 
 811         uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
 
 812         ResponseEntity<String> response =
 
 813                 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
 
 815         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 816         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 817         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 821     public void createVnfInstance() throws IOException {
 
 822         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 823                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 824                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 826         wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
 
 827                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 828                         .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
 
 829                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 830         wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
 
 831                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 832                         .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
 
 833                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 836         wireMockServer.stubFor(
 
 837                 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
 
 838                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 839                                 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
 
 840                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 842         wireMockServer.stubFor(get(urlMatching(
 
 843                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
 
 844                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 845                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
 
 846                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 849         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 850         RequestReferences requestReferences = new RequestReferences();
 
 851         requestReferences.setInstanceId("1882939");
 
 852         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 853         expectedResponse.setRequestReferences(requestReferences);
 
 854         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
 
 855         ResponseEntity<String> response =
 
 856                 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
 
 858         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 859         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 860         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 861         assertTrue(response.getBody().contains("1882939"));
 
 865     public void createVnfWithServiceRelatedInstanceFail() throws IOException {
 
 866         uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
 
 867         ResponseEntity<String> response =
 
 868                 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
 
 870         assertEquals(404, response.getStatusCode().value());
 
 874     public void createVnfInstanceInvalidVnfResource() throws IOException {
 
 875         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
 
 876         ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
 
 878         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
 879         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
 880         assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
 
 884     public void replaceVnfInstance() throws IOException {
 
 885         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 886                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 887                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 889         wireMockServer.stubFor(get(urlMatching(
 
 890                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
 
 891                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 892                                 .withBody(getWiremockResponseForCatalogdb(
 
 893                                         "vnfResourceCustomization_ReplaceVnf_Response.json"))
 
 894                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 896         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
 
 897                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 898                         .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
 
 899                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 901         wireMockServer.stubFor(get(urlMatching(
 
 902                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
 
 903                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 904                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
 
 905                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 907         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 908         RequestReferences requestReferences = new RequestReferences();
 
 909         requestReferences.setInstanceId("1882939");
 
 910         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 911         expectedResponse.setRequestReferences(requestReferences);
 
 912         uri = servInstanceuri + "v7"
 
 913                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
 914         ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
 
 916         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 917         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 918         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 922     public void replaceVnfInstanceNoCloudConfig() throws IOException {
 
 923         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/v1/getInfraActiveRequests.*"))
 
 924                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 925                         .withBodyFile("infra/VnfLookup.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 926         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
 927                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 928                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 929         wireMockServer.stubFor(get(urlMatching(
 
 930                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
 
 931                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 932                                 .withBody(getWiremockResponseForCatalogdb(
 
 933                                         "vnfResourceCustomization_ReplaceVnf_Response.json"))
 
 934                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 935         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
 
 936                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 937                         .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
 
 938                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 939         wireMockServer.stubFor(get(urlMatching(
 
 940                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
 
 941                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 942                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
 
 943                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 945         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 946         RequestReferences requestReferences = new RequestReferences();
 
 947         requestReferences.setInstanceId("1882939");
 
 948         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 949         expectedResponse.setRequestReferences(requestReferences);
 
 950         uri = servInstanceuri + "v7"
 
 951                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
 952         ResponseEntity<String> response =
 
 953                 sendRequest(inputStream("/ReplaceVnfNoCloudConfig.json"), uri, HttpMethod.POST, headers);
 
 955         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 956         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 957         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
 961     public void replaceVnfRecreateInstance() throws IOException {
 
 962         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
 
 963                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 964                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 966         wireMockServer.stubFor(get(urlMatching(
 
 967                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
 
 968                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 969                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
 
 970                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 972         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
 973                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 974                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
 975                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 977         wireMockServer.stubFor(get(urlMatching(
 
 978                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
 
 979                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
 980                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
 
 981                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
 984         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
 985         RequestReferences requestReferences = new RequestReferences();
 
 986         requestReferences.setInstanceId("1882939");
 
 987         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
 988         expectedResponse.setRequestReferences(requestReferences);
 
 989         uri = servInstanceuri + "v7"
 
 990                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
 991         ResponseEntity<String> response =
 
 992                 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
 
 993         logger.debug(response.getBody());
 
 995         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
 996         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
 997         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1001     public void recreateVnfInstance() throws IOException {
 
1002         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1003                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1004                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1006         wireMockServer.stubFor(get(urlMatching(
 
1007                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
 
1008                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1009                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
 
1010                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1012         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
1013                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1014                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
1015                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1017         wireMockServer.stubFor(get(urlMatching(
 
1018                 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
 
1019                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1020                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
 
1021                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1023         // expected response
 
1024         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1025         RequestReferences requestReferences = new RequestReferences();
 
1026         requestReferences.setInstanceId("1882939");
 
1027         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1028         expectedResponse.setRequestReferences(requestReferences);
 
1029         uri = servInstanceuri + "v7"
 
1030                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
 
1031         ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
 
1032         logger.debug(response.getBody());
 
1034         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1035         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1036         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1040     public void updateVnfInstance() throws IOException {
 
1041         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1042                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1043                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1045         wireMockServer.stubFor(get(urlMatching(
 
1046                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
 
1047                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1048                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
 
1049                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1051         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
1052                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1053                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
1054                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1056         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
1057                 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
 
1058                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1059                                 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
 
1060                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1062         // expected response
 
1063         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1064         RequestReferences requestReferences = new RequestReferences();
 
1065         requestReferences.setInstanceId("1882939");
 
1066         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1067         expectedResponse.setRequestReferences(requestReferences);
 
1068         uri = servInstanceuri + "v7"
 
1069                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1070         ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
 
1072         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1073         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1074         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1078     public void applyUpdatedConfig() throws IOException {
 
1079         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
 
1080                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1081                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1084         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
1085                 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
 
1086                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1087                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
 
1088                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1090         // expected response
 
1091         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1092         RequestReferences requestReferences = new RequestReferences();
 
1093         requestReferences.setInstanceId("1882939");
 
1094         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1095         expectedResponse.setRequestReferences(requestReferences);
 
1096         uri = servInstanceuri + "v7"
 
1097                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
 
1098         ResponseEntity<String> response =
 
1099                 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
 
1101         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1102         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1103         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1107     public void deleteVnfInstanceV5() throws IOException {
 
1108         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1109                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1110                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1112         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
1113                 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
 
1114                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1115                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
 
1116                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1117         // expected response
 
1118         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1119         RequestReferences requestReferences = new RequestReferences();
 
1120         requestReferences.setInstanceId("1882939");
 
1121         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1122         expectedResponse.setRequestReferences(requestReferences);
 
1123         uri = servInstanceuri + "v5"
 
1124                 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
 
1125         ResponseEntity<String> response =
 
1126                 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
 
1128         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1129         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1130         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1134     public void createCnfInstanceNoALaCarte() throws IOException {
 
1136         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1137                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1138                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1140         wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
 
1141                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1142                         .withBody(getWiremockResponseForCatalogdb("serviceCnf_Response.json"))
 
1143                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1145         // expected response
 
1146         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1147         RequestReferences requestReferences = new RequestReferences();
 
1148         requestReferences.setInstanceId("1882939");
 
1149         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1150         expectedResponse.setRequestReferences(requestReferences);
 
1151         uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/cnfs";
 
1152         ResponseEntity<String> response =
 
1153                 sendRequest(inputStream("/CnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
 
1155         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1156         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1157         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1158         assertTrue(response.getBody().contains("1882939"));
 
1162     public void createVfModuleInstance() throws IOException {
 
1163         wireMockServer.stubFor(get(urlMatching(
 
1164                 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
 
1165                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1166                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
 
1167                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1169         wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
 
1170                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1171                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1172                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1174         wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
 
1175                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1176                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1177                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1179         wireMockServer.stubFor(get(urlMatching(
 
1180                 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
 
1181                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1182                                 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1183                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1185         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
 
1186                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1187                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1189         wireMockServer.stubFor(get(urlMatching(
 
1190                 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1191                         + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
 
1192                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1193                                         .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
 
1194                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1195         // expected response
 
1196         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1197         RequestReferences requestReferences = new RequestReferences();
 
1198         requestReferences.setInstanceId("1882939");
 
1199         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1200         expectedResponse.setRequestReferences(requestReferences);
 
1201         uri = servInstanceuri + "v7"
 
1202                 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
 
1203         ResponseEntity<String> response =
 
1204                 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
 
1206         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1207         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1208         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1209         assertTrue(response.getBody().contains("1882939"));
 
1213     public void createVfModuleInstanceNoModelCustomization() throws IOException {
 
1214         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
 
1215                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1216                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1218         wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1219                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1220                         .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
 
1221                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1224                 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
 
1225                         + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1226                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1227                                         .withBody(getWiremockResponseForCatalogdb(
 
1228                                                 "vnfResourceCustomizationForVfModule_Response.json"))
 
1229                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1231         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
 
1232                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1233                         .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
 
1234                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1236         wireMockServer.stubFor(get(urlMatching(
 
1237                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
 
1238                         + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
 
1239                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1240                                         .withBody(getWiremockResponseForCatalogdb(
 
1241                                                 "vfModuleCustomizationPCM_Response.json"))
 
1242                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1244         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
 
1245                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1246                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1247                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1249         wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
 
1250                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1251                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1252                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1255         wireMockServer.stubFor(
 
1256                 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
 
1257                         + "[?]vnfComponentType=vfModule&action=createInstance"))
 
1258                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1259                                         .withBody(getWiremockResponseForCatalogdb(
 
1260                                                 "vnfComponentRecipeVNF_API_Response.json"))
 
1261                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1263         // expected response
 
1264         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1265         RequestReferences requestReferences = new RequestReferences();
 
1266         requestReferences.setInstanceId("1882939");
 
1267         requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1268         expectedResponse.setRequestReferences(requestReferences);
 
1269         uri = servInstanceuri + "v6"
 
1270                 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
 
1271         ResponseEntity<String> response =
 
1272                 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
 
1273         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1274         ObjectMapper mapper = new ObjectMapper();
 
1275         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1276         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1280     public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
 
1281         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1282                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1283                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1285         wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
 
1286                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1287                         .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
 
1288                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1291                 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
 
1292                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1293                                 .withBody(getWiremockResponseForCatalogdb(
 
1294                                         "vnfResourceCustomizationForVfModule_Response.json"))
 
1295                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1297         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
 
1298                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1299                         .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
 
1300                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1302         wireMockServer.stubFor(get(urlMatching(
 
1303                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
 
1304                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1305                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
 
1306                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1308         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
 
1309                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1310                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1311                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1313         wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
 
1314                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1315                         .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
 
1316                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1318         wireMockServer.stubFor(get(urlMatching(
 
1319                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1320                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
 
1321                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1322                                         .withBody(getWiremockResponseForCatalogdb(
 
1323                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1324                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1326         // expected response
 
1327         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1328         RequestReferences requestReferences = new RequestReferences();
 
1329         requestReferences.setInstanceId("1882939");
 
1330         requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1331         expectedResponse.setRequestReferences(requestReferences);
 
1332         uri = servInstanceuri + "v6"
 
1333                 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1334         ResponseEntity<String> response =
 
1335                 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
 
1338         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1339         ObjectMapper mapper = new ObjectMapper();
 
1340         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1341         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1345     public void createVfModuleInstanceNoRecipe() throws IOException {
 
1347         wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1348                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1349                         .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
 
1350                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1353                 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
 
1354                         + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
 
1355                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1356                                         .withBody(getWiremockResponseForCatalogdb(
 
1357                                                 "vnfResourceCustomizationForVfModule_Response.json"))
 
1358                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1360         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
 
1361                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1362                         .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
 
1363                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1365         wireMockServer.stubFor(
 
1366                 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
 
1367                         + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
 
1368                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1369                                         .withBody(getWiremockResponseForCatalogdb(
 
1370                                                 "vfModuleCustomizationPCM_Response.json"))
 
1371                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1373         uri = servInstanceuri + "v6"
 
1374                 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
 
1375         ResponseEntity<String> response =
 
1376                 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
 
1378         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1379         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
1380         assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
 
1384     public void replaceVfModuleInstance() throws IOException {
 
1385         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1386                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1387                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1390                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1391                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1392                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1393                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1394                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1396         wireMockServer.stubFor(get(urlMatching(
 
1397                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1398                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
 
1399                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1400                                         .withBody(getWiremockResponseForCatalogdb(
 
1401                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1402                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1403         // expected response
 
1404         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1405         RequestReferences requestReferences = new RequestReferences();
 
1406         requestReferences.setInstanceId("1882939");
 
1407         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1408         expectedResponse.setRequestReferences(requestReferences);
 
1409         uri = servInstanceuri + "v7"
 
1410                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
1411         ResponseEntity<String> response =
 
1412                 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
 
1414         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1415         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1416         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1420     public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException {
 
1421         wireMockServer.stubFor(
 
1422                 get(urlPathMatching("/aai/v\\d+/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000"))
 
1423                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1424                                 .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1425         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1426                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1427                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1429                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1430                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1431                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1432                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1433                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1434         wireMockServer.stubFor(get(urlMatching(
 
1435                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1436                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
 
1437                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1438                                         .withBody(getWiremockResponseForCatalogdb(
 
1439                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1440                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1441         // expected response
 
1442         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1443         RequestReferences requestReferences = new RequestReferences();
 
1444         requestReferences.setInstanceId("1882939");
 
1445         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1446         expectedResponse.setRequestReferences(requestReferences);
 
1447         uri = servInstanceuri + "v7"
 
1448                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
1449         ResponseEntity<String> response =
 
1450                 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
 
1452         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1453         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1454         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1458     public void updateVfModuleInstance() throws IOException {
 
1459         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1460                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1461                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1463         wireMockServer.stubFor(get(urlMatching(
 
1464                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
 
1465                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1466                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
 
1467                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1469         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1470                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1471                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1472                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1474         wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
 
1475                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1476                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1477                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1479         wireMockServer.stubFor(get(urlMatching(
 
1480                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1481                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
 
1482                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1483                                         .withBody(getWiremockResponseForCatalogdb(
 
1484                                                 "vnfComponentRecipe_GRAPI_Response.json"))
 
1485                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1487         // expected response
 
1488         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1489         RequestReferences requestReferences = new RequestReferences();
 
1490         requestReferences.setInstanceId("1882939");
 
1491         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1492         expectedResponse.setRequestReferences(requestReferences);
 
1493         uri = servInstanceuri + "v7"
 
1494                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1495         ResponseEntity<String> response =
 
1496                 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
 
1497         logger.debug(response.getBody());
 
1499         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1500         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1501         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1505     public void createVfModuleNoModelType() throws IOException {
 
1506         InfraActiveRequests expectedRecord = new InfraActiveRequests();
 
1507         expectedRecord.setRequestStatus("FAILED");
 
1508         expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
 
1509         expectedRecord.setProgress(100L);
 
1510         expectedRecord.setSource("VID");
 
1511         expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
 
1512         expectedRecord.setLastModifiedBy("APIH");
 
1513         expectedRecord.setVfModuleName("testVfModule2");
 
1514         expectedRecord.setVfModuleModelName("serviceModel");
 
1515         expectedRecord.setRequestScope("vfModule");
 
1516         expectedRecord.setRequestAction("createInstance");
 
1517         expectedRecord.setRequestorId("zz9999");
 
1518         expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
 
1519         // VnfType is not sent in this request, should be blank in db
 
1520         expectedRecord.setVnfType("");
 
1521         uri = servInstanceuri
 
1522                 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
 
1524         ResponseEntity<String> response =
 
1525                 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
 
1527         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1528         assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d",
 
1529                 response.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID).get(0));
 
1533     public void inPlaceSoftwareUpdate() throws IOException {
 
1534         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
 
1535                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1536                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1538         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
 
1539                 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
 
1540                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1541                                 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
 
1542                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1544         // expected response
 
1545         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1546         RequestReferences requestReferences = new RequestReferences();
 
1547         requestReferences.setInstanceId("1882939");
 
1548         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1549         expectedResponse.setRequestReferences(requestReferences);
 
1550         uri = servInstanceuri + "v7"
 
1551                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
 
1552         ResponseEntity<String> response =
 
1553                 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
 
1555         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1556         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1557         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1561     public void deleteVfModuleInstance() throws IOException {
 
1562         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1563                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1564                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1567                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1568                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1569                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1570                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1571                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1573         wireMockServer.stubFor(get(urlMatching(
 
1574                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1575                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
 
1576                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1577                                         .withBody(getWiremockResponseForCatalogdb(
 
1578                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1579                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1581         // expected response
 
1582         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1583         RequestReferences requestReferences = new RequestReferences();
 
1584         requestReferences.setInstanceId("1882939");
 
1585         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1586         expectedResponse.setRequestReferences(requestReferences);
 
1587         uri = servInstanceuri + "v7"
 
1588                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1589         ResponseEntity<String> response =
 
1590                 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
 
1592         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1593         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1594         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1598     public void deleteVfModuleNoModelInvariantId() throws IOException {
 
1599         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1600                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1601                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1603         wireMockServer.stubFor(get(urlMatching(
 
1604                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1605                         + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
 
1606                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1607                                         .withBody(getWiremockResponseForCatalogdb(
 
1608                                                 "vnfComponentRecipeDeleteVfModule_Response.json"))
 
1609                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1611         // expected response
 
1612         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1613         RequestReferences requestReferences = new RequestReferences();
 
1614         requestReferences.setInstanceId("1882939");
 
1615         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1616         expectedResponse.setRequestReferences(requestReferences);
 
1617         uri = servInstanceuri + "v7"
 
1618                 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
 
1619         ResponseEntity<String> response =
 
1620                 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
 
1622         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1623         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1624         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1628     public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
 
1629         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1630                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1631                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1634                 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
 
1635                         + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
 
1636                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1637                                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
1638                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1640         wireMockServer.stubFor(get(urlMatching(
 
1641                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1642                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
 
1643                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1644                                         .withBody(getWiremockResponseForCatalogdb(
 
1645                                                 "vnfComponentRecipeDeactivate_Response.json"))
 
1646                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1648         // expected response
 
1649         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1650         RequestReferences requestReferences = new RequestReferences();
 
1651         requestReferences.setInstanceId("1882939");
 
1652         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1653         expectedResponse.setRequestReferences(requestReferences);
 
1654         uri = servInstanceuri + "v7"
 
1655                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
 
1656         ResponseEntity<String> response =
 
1657                 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
 
1659         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1660         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1661         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1665     public void createVolumeGroupInstance() throws IOException {
 
1666         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1667                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1668                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1670         wireMockServer.stubFor(get(urlMatching(
 
1671                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
 
1672                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1673                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
 
1674                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1676         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1677                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1678                         .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
 
1679                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1681         wireMockServer.stubFor(get(urlMatching(
 
1682                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1683                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
 
1684                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1685                                         .withBody(getWiremockResponseForCatalogdb(
 
1686                                                 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
 
1687                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1689         // expected response
 
1690         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1691         RequestReferences requestReferences = new RequestReferences();
 
1692         requestReferences.setInstanceId("1882939");
 
1693         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1694         expectedResponse.setRequestReferences(requestReferences);
 
1695         uri = servInstanceuri + "v7"
 
1696                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
 
1697         ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
 
1699         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1700         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1701         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1702         assertTrue(response.getBody().contains("1882939"));
 
1706     public void updateVolumeGroupInstance() throws IOException {
 
1707         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1708                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1709                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1711         wireMockServer.stubFor(get(urlMatching(
 
1712                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
 
1713                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1714                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
 
1715                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1717         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1718                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1719                         .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
 
1720                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1722         wireMockServer.stubFor(get(urlMatching(
 
1723                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1724                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
 
1725                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1726                                         .withBody(getWiremockResponseForCatalogdb(
 
1727                                                 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
 
1728                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1730         // expected response
 
1731         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1732         RequestReferences requestReferences = new RequestReferences();
 
1733         requestReferences.setInstanceId("1882939");
 
1734         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1735         expectedResponse.setRequestReferences(requestReferences);
 
1736         uri = servInstanceuri + "v7"
 
1737                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1738         ResponseEntity<String> response =
 
1739                 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
 
1741         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1742         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1743         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1747     public void deleteVolumeGroupInstance() throws IOException {
 
1748         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1749                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1750                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1752         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1753                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1754                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1756         wireMockServer.stubFor(get(urlMatching(
 
1757                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
 
1758                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1759                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
 
1760                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1762         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
1763                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1764                         .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
 
1765                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1767         wireMockServer.stubFor(get(urlMatching(
 
1768                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
1769                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
 
1770                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1771                                         .withBody(getWiremockResponseForCatalogdb(
 
1772                                                 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
 
1773                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1775         // expected response
 
1776         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1777         RequestReferences requestReferences = new RequestReferences();
 
1778         requestReferences.setInstanceId("1882939");
 
1779         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1780         expectedResponse.setRequestReferences(requestReferences);
 
1781         uri = servInstanceuri + "v7"
 
1782                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
 
1783         ResponseEntity<String> response =
 
1784                 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
 
1786         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1787         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1788         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1792     public void createNetworkInstance() throws IOException {
 
1793         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1794                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1795                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1797         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1798                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1799                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1800                         .withStatus(HttpStatus.SC_OK)));
 
1802         wireMockServer.stubFor(
 
1803                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1804                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1805                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1806                                 .withStatus(HttpStatus.SC_OK)));
 
1808         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1809                 + "modelName=GR-API-DEFAULT&action=createInstance"))
 
1810                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1811                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1812                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1814         // expected response
 
1815         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1816         RequestReferences requestReferences = new RequestReferences();
 
1817         requestReferences.setInstanceId("1882939");
 
1818         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1819         expectedResponse.setRequestReferences(requestReferences);
 
1820         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
1821         ResponseEntity<String> response =
 
1822                 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
 
1824         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1825         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1826         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1830     public void updateNetworkInstance() throws IOException {
 
1831         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1832                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1833                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1835         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1836                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1837                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1838                         .withStatus(HttpStatus.SC_OK)));
 
1840         wireMockServer.stubFor(
 
1841                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1842                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1843                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1844                                 .withStatus(HttpStatus.SC_OK)));
 
1846         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1847                 + "modelName=GR-API-DEFAULT&action=updateInstance"))
 
1848                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1849                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1850                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1851         // expected response
 
1852         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1853         RequestReferences requestReferences = new RequestReferences();
 
1854         requestReferences.setInstanceId("1882939");
 
1855         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1856         expectedResponse.setRequestReferences(requestReferences);
 
1857         uri = servInstanceuri + "v7"
 
1858                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1859         ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
 
1861         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1862         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1863         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1864         assertTrue(response.getBody().contains("1882939"));
 
1868     public void deleteNetworkInstance() throws IOException {
 
1869         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1870                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1871                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1873         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
1874                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1875                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
1876                         .withStatus(HttpStatus.SC_OK)));
 
1878         wireMockServer.stubFor(
 
1879                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
1880                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1881                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
1882                                 .withStatus(HttpStatus.SC_OK)));
 
1884         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1885                 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
 
1886                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1887                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1888                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1890         // expected response
 
1891         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1892         RequestReferences requestReferences = new RequestReferences();
 
1893         requestReferences.setInstanceId("1882939");
 
1894         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1895         expectedResponse.setRequestReferences(requestReferences);
 
1896         uri = servInstanceuri + "v7"
 
1897                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1898         ResponseEntity<String> response =
 
1899                 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
 
1901         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1902         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1903         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1907     public void deleteNetworkInstanceNoReqParams() throws IOException {
 
1908         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1909                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1910                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1912         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
1913                 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
 
1914                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1915                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
1916                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1919         // expected response
 
1920         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
1921         RequestReferences requestReferences = new RequestReferences();
 
1922         requestReferences.setInstanceId("1882939");
 
1923         requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
1924         expectedResponse.setRequestReferences(requestReferences);
 
1925         uri = servInstanceuri + "v6"
 
1926                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1927         ResponseEntity<String> response =
 
1928                 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
 
1930         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
1931         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
1932         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
1936     public void convertJsonToServiceInstanceRequestFail() throws IOException {
 
1938         InfraActiveRequests expectedRecord = new InfraActiveRequests();
 
1939         expectedRecord.setRequestStatus("FAILED");
 
1940         expectedRecord.setStatusMessage("Error mapping request: ");
 
1941         expectedRecord.setProgress(100L);
 
1942         expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
 
1943         expectedRecord.setLastModifiedBy("APIH");
 
1944         expectedRecord.setRequestScope("network");
 
1945         expectedRecord.setRequestAction("deleteInstance");
 
1946         expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
 
1948         uri = servInstanceuri + "v6"
 
1949                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
1950         ResponseEntity<String> response =
 
1951                 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
 
1955         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1959     public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
 
1960         uri = servInstanceuri + "v5"
 
1961                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
 
1962         ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
 
1964         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
1968     public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
 
1969         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
1970                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1971                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
1973         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
1974         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
1975         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
1976         serviceRecipe.setAction(Action.createInstance.toString());
 
1977         serviceRecipe.setId(1);
 
1978         serviceRecipe.setRecipeTimeout(180);
 
1979         Service defaultService = new Service();
 
1980         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
1982         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
1983                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1984                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
1986         wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
 
1987                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1988                         .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
 
1990         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
1991                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
1992                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
1994         uri = servInstanceuri + "v7" + "/serviceInstances";
 
1995         ResponseEntity<String> response =
 
1996                 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
 
1998         // expected response
 
1999         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2000         RequestReferences requestReferences = new RequestReferences();
 
2001         requestReferences.setInstanceId("1882939");
 
2002         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2003         expectedResponse.setRequestReferences(requestReferences);
 
2005         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2006         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2007         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2011     public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
 
2012         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2013                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2014                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2016         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2017                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2018                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
2019                         .withStatus(HttpStatus.SC_OK)));
 
2021         wireMockServer.stubFor(
 
2022                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
2023                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2024                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
2025                                 .withStatus(HttpStatus.SC_OK)));
 
2027         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2028                 + "modelName=GR-API-DEFAULT&action=createInstance"))
 
2029                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2030                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
2031                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2033         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2034         ResponseEntity<String> response =
 
2035                 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
 
2037         // expected response
 
2038         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2039         RequestReferences requestReferences = new RequestReferences();
 
2040         requestReferences.setInstanceId("1882939");
 
2041         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2042         expectedResponse.setRequestReferences(requestReferences);
 
2044         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2045         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2046         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2050     public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
 
2051         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2052                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2053                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2055         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2056         ResponseEntity<String> response =
 
2057                 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
 
2059         // expected response
 
2060         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2061         RequestReferences requestReferences = new RequestReferences();
 
2062         requestReferences.setInstanceId("1882939");
 
2063         expectedResponse.setRequestReferences(requestReferences);
 
2065         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2069     public void createNetworkInstanceTestApiGrApi() throws IOException {
 
2070         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2071                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2072                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2074         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2075                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2076                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
2077                         .withStatus(HttpStatus.SC_OK)));
 
2079         wireMockServer.stubFor(
 
2080                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
2081                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2082                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
2083                                 .withStatus(HttpStatus.SC_OK)));
 
2085         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2086                 + "modelName=GR-API-DEFAULT&action=createInstance"))
 
2087                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2088                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
2089                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2091         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2092         ResponseEntity<String> response =
 
2093                 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
 
2095         // expected response
 
2096         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2097         RequestReferences requestReferences = new RequestReferences();
 
2098         requestReferences.setInstanceId("1882939");
 
2099         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2100         expectedResponse.setRequestReferences(requestReferences);
 
2102         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2103         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2104         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2108     public void createNetworkInstanceTestApiVnfApi() throws IOException {
 
2109         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
 
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(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2114                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2115                         .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
 
2116                         .withStatus(HttpStatus.SC_OK)));
 
2118         wireMockServer.stubFor(
 
2119                 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
 
2120                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2121                                 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
 
2122                                 .withStatus(HttpStatus.SC_OK)));
 
2124         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2125                 + "modelName=VNF-API-DEFAULT&action=createInstance"))
 
2126                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2127                                 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
 
2128                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2130         uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
 
2131         ResponseEntity<String> response =
 
2132                 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
 
2134         // expected response
 
2135         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2136         RequestReferences requestReferences = new RequestReferences();
 
2137         requestReferences.setInstanceId("1882939");
 
2138         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2139         expectedResponse.setRequestReferences(requestReferences);
 
2141         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2142         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2143         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2147     public void activateServiceInstanceRequestStatus() throws IOException {
 
2148         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2149         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2150         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2151         serviceRecipe.setAction(Action.createInstance.toString());
 
2152         serviceRecipe.setId(1);
 
2153         serviceRecipe.setRecipeTimeout(180);
 
2154         Service defaultService = new Service();
 
2155         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2157         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2158                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2159                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2161         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2162                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2163                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2165         wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
 
2166                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2167                         .withBodyFile("/aai/ServiceFromAAI.json").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)));
 
2174         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2175         RequestReferences requestReferences = new RequestReferences();
 
2176         requestReferences.setInstanceId("1882939");
 
2177         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2178         expectedResponse.setRequestReferences(requestReferences);
 
2179         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
 
2180         ResponseEntity<String> response =
 
2181                 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
 
2183         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2184         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2185         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2189     public void invalidRequestId() throws IOException {
 
2190         String illegalRequestId = "1234";
 
2191         HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
 
2192         ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
 
2193         uri = servInstanceuri + "v5/serviceInstances";
 
2194         ResponseEntity<String> response =
 
2195                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
 
2197         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2198         assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
 
2202     public void invalidBPELResponse() throws IOException {
 
2204         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2205         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2206         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2207         serviceRecipe.setAction(Action.createInstance.toString());
 
2208         serviceRecipe.setId(1);
 
2209         serviceRecipe.setRecipeTimeout(180);
 
2210         Service defaultService = new Service();
 
2211         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2213         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
2214                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2215                 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2217         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2218                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2219                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2221         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2222                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2223                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2225         uri = servInstanceuri + "v5/serviceInstances";
 
2226         ResponseEntity<String> response =
 
2227                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2229         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2230         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2231         assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
 
2232                 realResponse.getServiceException().getText());
 
2236     public void unauthorizedBPELResponse() throws IOException {
 
2238         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2239         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2240         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2241         serviceRecipe.setAction(Action.createInstance.toString());
 
2242         serviceRecipe.setId(1);
 
2243         serviceRecipe.setRecipeTimeout(180);
 
2244         Service defaultService = new Service();
 
2245         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2247         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2248                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2249                         .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
 
2251         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2252                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2253                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2255         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2256                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2257                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2259         uri = servInstanceuri + "v5/serviceInstances";
 
2260         ResponseEntity<String> response =
 
2261                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2263         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2264         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2265         assertEquals("Request Failed due to BPEL error with HTTP Status = 401 UNAUTHORIZED",
 
2266                 realResponse.getServiceException().getText());
 
2270     public void invalidBPELResponse2() throws IOException {
 
2272         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2273         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2274         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2275         serviceRecipe.setAction(Action.createInstance.toString());
 
2276         serviceRecipe.setId(1);
 
2277         serviceRecipe.setRecipeTimeout(180);
 
2278         Service defaultService = new Service();
 
2279         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2281         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
2282                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2283                 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2285         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2286                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2287                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2289         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2290                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2291                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2292         uri = servInstanceuri + "v5/serviceInstances";
 
2293         ResponseEntity<String> response =
 
2294                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2296         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2297         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2298         assertTrue(realResponse.getServiceException().getText()
 
2299                 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
 
2303     public void createMacroServiceInstance() throws IOException {
 
2304         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2305         serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
 
2306         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2307         serviceRecipe.setAction(Action.createInstance.toString());
 
2308         serviceRecipe.setId(1);
 
2309         serviceRecipe.setRecipeTimeout(180);
 
2310         Service defaultService = new Service();
 
2311         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2313         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
 
2314                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2315                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2317         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
 
2318                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2319                 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2321         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2322                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2323                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2325         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2326                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2327                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2330         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2331         RequestReferences requestReferences = new RequestReferences();
 
2332         requestReferences.setInstanceId("1882939");
 
2333         requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2334         expectedResponse.setRequestReferences(requestReferences);
 
2335         uri = servInstanceuri + "v5";
 
2336         ResponseEntity<String> response =
 
2337                 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
 
2340         assertEquals(404, response.getStatusCode().value());
 
2344     public void testUserParams() throws IOException {
 
2345         ObjectMapper mapper = new ObjectMapper();
 
2346         ServiceInstancesRequest request =
 
2347                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2348         RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
 
2349         String userParamsTxt = inputStream("/userParams.txt");
 
2351         List<Map<String, Object>> userParams = requestHandlerUtils.configureUserParams(requestParameters);
 
2352         System.out.println(userParams);
 
2353         assertTrue(userParams.size() > 0);
 
2354         assertTrue(userParams.get(0).containsKey("name"));
 
2355         assertTrue(userParams.get(0).containsKey("value"));
 
2356         assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
 
2360     public void testConfigureCloudConfig() throws IOException {
 
2361         ObjectMapper mapper = new ObjectMapper();
 
2362         ServiceInstancesRequest request =
 
2363                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2364         CloudConfiguration cloudConfig =
 
2365                 requestHandlerUtils.configureCloudConfig(request.getRequestDetails().getRequestParameters());
 
2367         assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
 
2368         assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
 
2372     public void testMapToLegacyRequest() throws IOException {
 
2373         ObjectMapper mapper = new ObjectMapper();
 
2374         ServiceInstancesRequest request =
 
2375                 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2376         ServiceInstancesRequest expected =
 
2377                 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
 
2378         requestHandlerUtils.mapToLegacyRequest(request.getRequestDetails());
 
2379         System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
 
2380         assertThat(request, sameBeanAs(expected));
 
2384     public void scaleOutVfModule() throws IOException {
 
2385         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2386                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2387                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2389         wireMockServer.stubFor(get(urlMatching(
 
2390                 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
 
2391                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2392                                 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
 
2393                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2395         wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
 
2396                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2397                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
2398                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2400         wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
 
2401                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2402                         .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
 
2403                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2406         wireMockServer.stubFor(get(urlMatching(
 
2407                 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
 
2408                         + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
 
2409                                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2410                                         .withBody(getWiremockResponseForCatalogdb(
 
2411                                                 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
 
2412                                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2414         wireMockServer.stubFor(get(urlMatching(
 
2415                 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
 
2416                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2417                                 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
 
2418                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2420         // expected response
 
2421         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2422         RequestReferences requestReferences = new RequestReferences();
 
2423         requestReferences.setInstanceId("1882939");
 
2424         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2425         expectedResponse.setRequestReferences(requestReferences);
 
2426         uri = servInstanceuri + "v7"
 
2427                 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
 
2428         ResponseEntity<String> response =
 
2429                 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
 
2431         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2432         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2433         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2434         assertTrue(response.getBody().contains("1882939"));
 
2438     public void createServiceInstanceBadResponse() throws IOException {
 
2439         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2440         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2441         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2442         serviceRecipe.setAction(Action.createInstance.toString());
 
2443         serviceRecipe.setId(1);
 
2444         serviceRecipe.setRecipeTimeout(180);
 
2445         Service defaultService = new Service();
 
2446         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2448         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2449                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2450                         .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2452         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2453                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2454                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2456         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2457                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2458                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2460         uri = servInstanceuri + "v5/serviceInstances";
 
2461         ResponseEntity<String> response =
 
2462                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2464         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2465         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2466         assertEquals("Exception caught mapping Camunda JSON response to object",
 
2467                 realResponse.getServiceException().getText());
 
2471     public void createServiceInstanceDuplicateError() throws IOException {
 
2472         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2473                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2474                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2476         uri = servInstanceuri + "v5/serviceInstances";
 
2477         ResponseEntity<String> response =
 
2478                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2480         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2481         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2483                 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
 
2484                 realResponse.getServiceException().getText());
 
2488     public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
 
2489         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2490                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2491                         .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
 
2492                         .withStatus(HttpStatus.SC_ACCEPTED)));
 
2493         wireMockServer.stubFor(get(
 
2494                 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
 
2495                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2496                                 .withBodyFile("Camunda/HistoryCheckResponse.json")
 
2497                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2499         uri = servInstanceuri + "v5/serviceInstances";
 
2500         ResponseEntity<String> response =
 
2501                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2503         assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
 
2504         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2506                 "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.",
 
2507                 realResponse.getServiceException().getText());
 
2511     public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
 
2512         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2513                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2514                         .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
 
2515                         .withStatus(HttpStatus.SC_ACCEPTED)));
 
2516         wireMockServer.stubFor(get(
 
2517                 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
 
2518                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2519                                 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2521         uri = servInstanceuri + "v5/serviceInstances";
 
2522         ResponseEntity<String> response =
 
2523                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2525         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2526         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2528                 "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: [no body]",
 
2529                 realResponse.getServiceException().getText());
 
2533     public void createServiceInstanceDuplicate() throws IOException {
 
2534         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
 
2535                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2536                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2538         uri = servInstanceuri + "v5/serviceInstances";
 
2539         ResponseEntity<String> response =
 
2540                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2542         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2543         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2545                 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
 
2546                 realResponse.getServiceException().getText());
 
2550     public void createServiceInstanceSaveError() throws IOException {
 
2551         ServiceRecipe serviceRecipe = new ServiceRecipe();
 
2552         serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
 
2553         serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2554         serviceRecipe.setAction(Action.createInstance.toString());
 
2555         serviceRecipe.setId(1);
 
2556         serviceRecipe.setRecipeTimeout(180);
 
2557         Service defaultService = new Service();
 
2558         defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
 
2559         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
 
2560                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2561                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2562         wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
 
2563                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2564                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2566         wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
 
2567                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2568                         .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
 
2570         uri = servInstanceuri + "v5/serviceInstances";
 
2571         ResponseEntity<String> response =
 
2572                 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
 
2574         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2575         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2577                 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
 
2578                 realResponse.getServiceException().getText());
 
2582     public void createPortConfigurationSaveError() throws IOException {
 
2583         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
 
2584                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2585                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2586         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
 
2587                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2588                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2590         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
2591         ResponseEntity<String> response =
 
2592                 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
 
2594         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2595         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2597                 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
 
2598                 realResponse.getServiceException().getText());
 
2602     public void createPortConfigDbUpdateError() throws IOException {
 
2603         wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
 
2604                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2605                         .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
 
2607         uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
 
2608         ResponseEntity<String> response =
 
2609                 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
 
2611         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
2612         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2614                 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
 
2615                 realResponse.getServiceException().getText());
 
2619     public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
 
2620         TestAppender.events.clear();
 
2621         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2622                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2623                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2625         wireMockServer.stubFor(get(urlMatching(
 
2626                 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
 
2627                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2628                                 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
 
2629                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2631         wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
 
2632                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2633                         .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
 
2634                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2636         wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
 
2637                 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
 
2638                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2639                                 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
 
2640                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2641         headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
 
2643         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2644         RequestReferences requestReferences = new RequestReferences();
 
2645         requestReferences.setInstanceId("1882939");
 
2646         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2647         expectedResponse.setRequestReferences(requestReferences);
 
2648         uri = servInstanceuri
 
2649                 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
 
2650         ResponseEntity<String> response =
 
2651                 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
 
2653         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2654         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2655         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2656         assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
 
2660     public void createInstanceGroup() throws IOException {
 
2661         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2662                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2663                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2666         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2667         RequestReferences requestReferences = new RequestReferences();
 
2668         requestReferences.setInstanceId("1882939");
 
2669         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2670         expectedResponse.setRequestReferences(requestReferences);
 
2671         uri = servInstanceuri + "/v7/instanceGroups";
 
2672         ResponseEntity<String> response =
 
2673                 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
 
2676         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2677         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2678         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2682     public void deleteInstanceGroup() throws IOException {
 
2683         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2684                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2685                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2688         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2689         RequestReferences requestReferences = new RequestReferences();
 
2690         requestReferences.setInstanceId("1882939");
 
2691         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2692         expectedResponse.setRequestReferences(requestReferences);
 
2693         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2694         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
 
2697         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2698         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2699         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2703     public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
 
2704         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2705         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
 
2707         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2708         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2709         assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
 
2713     public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
 
2714         HttpHeaders noPartnerHeaders = new HttpHeaders();
 
2715         noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
 
2716         noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
 
2717         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2718         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
 
2720         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2721         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2722         assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
 
2726     public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
 
2727         HttpHeaders noRequestorIdHheaders = new HttpHeaders();
 
2728         noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
 
2729         noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
 
2731         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2732         RequestReferences requestReferences = new RequestReferences();
 
2733         requestReferences.setInstanceId("1882939");
 
2734         expectedResponse.setRequestReferences(requestReferences);
 
2735         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
 
2736         ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
 
2739         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2740         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2741         assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
 
2745     public void addMembers() throws IOException {
 
2746         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2747                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2748                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2750         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2751         RequestReferences requestReferences = new RequestReferences();
 
2752         requestReferences.setInstanceId("1882939");
 
2753         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2754         expectedResponse.setRequestReferences(requestReferences);
 
2755         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
 
2756         ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
 
2759         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2760         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2761         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2765     public void removeMembers() throws IOException {
 
2766         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2767                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2768                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2770         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2771         RequestReferences requestReferences = new RequestReferences();
 
2772         requestReferences.setInstanceId("1882939");
 
2773         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2774         expectedResponse.setRequestReferences(requestReferences);
 
2775         uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
 
2776         ResponseEntity<String> response =
 
2777                 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
 
2780         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2781         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2782         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2786     public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
 
2787         wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
 
2788                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2789                         .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2791         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2792                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2793                         .withStatus(HttpStatus.SC_NOT_FOUND)));
 
2795         wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
 
2796                 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
 
2797                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2798                                 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
 
2799                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2801         // expected response
 
2802         ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
 
2803         RequestReferences requestReferences = new RequestReferences();
 
2804         requestReferences.setInstanceId("1882939");
 
2805         requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
 
2806         expectedResponse.setRequestReferences(requestReferences);
 
2807         uri = servInstanceuri + "v7"
 
2808                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
2809         ResponseEntity<String> response =
 
2810                 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
 
2812         assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
 
2813         ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
 
2814         assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
 
2818     public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
 
2819         wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
 
2820                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2821                         .withStatus(HttpStatus.SC_NOT_FOUND)));
 
2823         uri = servInstanceuri + "v7"
 
2824                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
 
2825         ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
 
2827         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
 
2828         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
2829         assertEquals(realResponse.getServiceException().getText(),
 
2830                 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
 
2834     public void setServiceTypeTestALaCarte() throws JsonProcessingException {
 
2835         String requestScope = ModelType.service.toString();
 
2836         Boolean aLaCarteFlag = true;
 
2837         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2838         RequestDetails requestDetails = new RequestDetails();
 
2839         RequestInfo requestInfo = new RequestInfo();
 
2840         requestInfo.setSource("VID");
 
2841         requestDetails.setRequestInfo(requestInfo);
 
2842         sir.setRequestDetails(requestDetails);
 
2843         Service defaultService = new Service();
 
2844         defaultService.setServiceType("testServiceTypeALaCarte");
 
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, "testServiceTypeALaCarte");
 
2855     public void setServiceTypeTest() throws JsonProcessingException {
 
2856         String requestScope = ModelType.service.toString();
 
2857         Boolean aLaCarteFlag = false;
 
2858         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2859         RequestDetails requestDetails = new RequestDetails();
 
2860         RequestInfo requestInfo = new RequestInfo();
 
2861         ModelInfo modelInfo = new ModelInfo();
 
2862         modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
 
2863         requestInfo.setSource("VID");
 
2864         requestDetails.setModelInfo(modelInfo);
 
2865         requestDetails.setRequestInfo(requestInfo);
 
2866         sir.setRequestDetails(requestDetails);
 
2867         Service defaultService = new Service();
 
2868         defaultService.setServiceType("testServiceType");
 
2870         wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
 
2871                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2872                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2874         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2875         assertEquals(serviceType, "testServiceType");
 
2879     public void setServiceTypeTestDefault() throws JsonProcessingException {
 
2880         String requestScope = ModelType.service.toString();
 
2881         Boolean aLaCarteFlag = false;
 
2882         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2883         RequestDetails requestDetails = new RequestDetails();
 
2884         RequestInfo requestInfo = new RequestInfo();
 
2885         ModelInfo modelInfo = new ModelInfo();
 
2886         modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
 
2887         requestInfo.setSource("VID");
 
2888         requestDetails.setModelInfo(modelInfo);
 
2889         requestDetails.setRequestInfo(requestInfo);
 
2890         sir.setRequestDetails(requestDetails);
 
2891         Service defaultService = new Service();
 
2892         defaultService.setServiceType("testServiceType");
 
2894         wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
 
2895                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2896                         .withStatus(HttpStatus.SC_NOT_FOUND)));
 
2897         wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
 
2898                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2899                         .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
 
2901         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2902         assertEquals(serviceType, "testServiceType");
 
2906     public void setServiceTypeTestNetwork() {
 
2907         String requestScope = ModelType.network.toString();
 
2908         Boolean aLaCarteFlag = null;
 
2909         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2910         RequestDetails requestDetails = new RequestDetails();
 
2911         RequestInfo requestInfo = new RequestInfo();
 
2912         ModelInfo modelInfo = new ModelInfo();
 
2913         modelInfo.setModelName("networkModelName");
 
2914         requestInfo.setSource("VID");
 
2915         requestDetails.setModelInfo(modelInfo);
 
2916         requestDetails.setRequestInfo(requestInfo);
 
2917         sir.setRequestDetails(requestDetails);
 
2919         String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
 
2920         assertEquals(serviceType, "networkModelName");
 
2924     public void setServiceInstanceIdInstanceGroupTest() throws JsonMappingException, IOException {
 
2925         String requestScope = "instanceGroup";
 
2926         ServiceInstancesRequest sir =
 
2927                 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
 
2928         assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
 
2929                 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
 
2933     public void setServiceInstanceIdTest() {
 
2934         String requestScope = "vnf";
 
2935         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2936         sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2937         assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
 
2938                 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
 
2942     public void setServiceInstanceIdReturnNullTest() {
 
2943         String requestScope = "vnf";
 
2944         ServiceInstancesRequest sir = new ServiceInstancesRequest();
 
2945         assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
 
2949     public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
 
2950         wireMockServer.stubFor(get(
 
2951                 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
 
2952                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2953                                 .withBodyFile("Camunda/HistoryCheckResponse.json")
 
2954                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2956         InfraActiveRequests duplicateRecord = new InfraActiveRequests();
 
2957         duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2958         boolean inProgress = false;
 
2959         inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
 
2960         assertTrue(inProgress);
 
2964     public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
 
2965         wireMockServer.stubFor(get(
 
2966                 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
 
2967                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
 
2968                                 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
 
2970         InfraActiveRequests duplicateRecord = new InfraActiveRequests();
 
2971         duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
 
2972         boolean inProgress = false;
 
2973         inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
 
2974         assertFalse(inProgress);
 
2978     public void handleReplaceInstance_Test() throws JsonMappingException, IOException {
 
2979         String replaceVfModule = inputStream("/ReplaceVfModule.json");
 
2980         ObjectMapper mapper = new ObjectMapper();
 
2981         ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
 
2982         Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
 
2983         assertEquals(Action.replaceInstance, action);
 
2987     public void handleReplaceInstance_retainAssignments_Test() throws JsonMappingException, IOException {
 
2988         String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
 
2989         ObjectMapper mapper = new ObjectMapper();
 
2990         ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
 
2991         Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
 
2992         assertEquals(Action.replaceInstanceRetainAssignments, action);
 
2996     public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
 
2997         RequestError expectedResponse =
 
2998                 mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
 
2999         uri = servInstanceuri + "v7"
 
3000                 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
 
3001         ResponseEntity<String> response =
 
3002                 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
 
3004         assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
 
3005         RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
 
3006         assertThat(expectedResponse, sameBeanAs(realResponse));