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.JsonParseException;
79 import com.fasterxml.jackson.core.JsonProcessingException;
80 import com.fasterxml.jackson.databind.DeserializationFeature;
81 import com.fasterxml.jackson.databind.JsonMappingException;
82 import com.fasterxml.jackson.databind.ObjectMapper;
83 import com.github.tomakehurst.wiremock.http.Fault;
85 public class ServiceInstancesTest extends BaseTest {
87 private final ObjectMapper mapper = new ObjectMapper();
90 private ServiceInstances servInstances;
93 private RequestHandlerUtils requestHandlerUtils;
95 @Value("${wiremock.server.port}")
96 private String wiremockPort;
98 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
99 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
100 private final String orchestration_path = "/onap/so/infra";
103 private URL selfLink;
104 private URL initialUrl;
105 private int initialPort;
106 private HttpHeaders headers;
109 public void beforeClass() {
110 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
112 headers = new HttpHeaders();
113 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
114 headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
115 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
116 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
117 headers.set(ONAP_PARTNER_NAME, "VID");
118 headers.set(REQUESTOR_ID, "xxxxxx");
119 try { // generate one-time port number to avoid RANDOM port number later.
120 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH, orchestration_path));
121 initialPort = initialUrl.getPort();
122 } catch (MalformedURLException e) {
125 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse()
126 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
127 Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
130 public String inputStream(String JsonInput) throws IOException {
131 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
132 return new String(Files.readAllBytes(Paths.get(JsonInput)));
135 private URL createExpectedSelfLink(String version, String requestId) {
136 System.out.println("createdUrl: " + initialUrl.toString());
138 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
139 } catch (MalformedURLException e) {
145 private String getWiremockResponseForCatalogdb(String file) {
147 File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
148 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
149 "localhost:" + wiremockPort);
150 } catch (IOException e) {
157 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
158 HttpHeaders headers) {
160 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
161 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
163 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
164 headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
167 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
169 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
171 return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
174 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
175 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
179 public void createServiceInstanceVIDDefault() throws IOException {
180 TestAppender.events.clear();
182 ServiceRecipe serviceRecipe = new ServiceRecipe();
183 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
184 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
185 serviceRecipe.setAction(Action.createInstance.toString());
186 serviceRecipe.setId(1);
187 serviceRecipe.setRecipeTimeout(180);
188 Service defaultService = new Service();
189 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
192 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
193 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
194 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
196 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
197 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
198 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
200 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
201 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
202 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
205 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
206 RequestReferences requestReferences = new RequestReferences();
207 requestReferences.setInstanceId("1882939");
208 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
209 expectedResponse.setRequestReferences(requestReferences);
210 uri = servInstanceuri + "v5/serviceInstances";
211 ResponseEntity<String> response =
212 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
215 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
216 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
217 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
221 public void createServiceInstanceServiceInstancesUri() throws IOException {
222 ServiceRecipe serviceRecipe = new ServiceRecipe();
223 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
224 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
225 serviceRecipe.setAction(Action.createInstance.toString());
226 serviceRecipe.setId(1);
227 serviceRecipe.setRecipeTimeout(180);
228 Service defaultService = new Service();
229 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
231 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
232 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
233 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
236 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
237 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
238 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
240 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
241 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
242 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
244 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
245 RequestReferences requestReferences = new RequestReferences();
246 requestReferences.setInstanceId("1882939");
247 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
248 expectedResponse.setRequestReferences(requestReferences);
249 uri = servInstanceuri + "v5";
250 ResponseEntity<String> response =
251 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
254 assertEquals(404, response.getStatusCode().value());
255 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
259 public void createServiceInstanceBpelStatusError() throws IOException {
260 ServiceRecipe serviceRecipe = new ServiceRecipe();
261 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
262 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
263 serviceRecipe.setAction(Action.createInstance.toString());
264 serviceRecipe.setId(1);
265 serviceRecipe.setRecipeTimeout(180);
266 Service defaultService = new Service();
267 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
270 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
271 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
272 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
275 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
276 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
277 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
279 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
280 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
281 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
283 uri = servInstanceuri + "v5/serviceInstances";
284 ResponseEntity<String> response =
285 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
287 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
291 public void createServiceInstanceBadGateway() throws IOException {
292 ServiceRecipe serviceRecipe = new ServiceRecipe();
293 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
294 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
295 serviceRecipe.setAction(Action.createInstance.toString());
296 serviceRecipe.setId(1);
297 serviceRecipe.setRecipeTimeout(180);
298 Service defaultService = new Service();
299 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
301 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
302 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
304 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
305 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
306 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
308 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
310 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
312 uri = servInstanceuri + "v5/serviceInstances";
313 ResponseEntity<String> response =
314 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
316 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
320 public void createServiceInstanceEmptyResponse() throws IOException {
321 ServiceRecipe serviceRecipe = new ServiceRecipe();
322 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
323 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
324 serviceRecipe.setAction(Action.createInstance.toString());
325 serviceRecipe.setId(1);
326 serviceRecipe.setRecipeTimeout(180);
327 Service defaultService = new Service();
328 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
330 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
331 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
333 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
335 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
337 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
339 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
341 uri = servInstanceuri + "v5/serviceInstances";
342 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
344 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
348 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
349 TestAppender.events.clear();
350 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
351 HttpHeaders requestIDheaders = new HttpHeaders();
352 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
353 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
354 HttpMethod.POST, requestIDheaders);
356 Service defaultService = new Service();
357 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
359 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
360 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
361 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
364 wireMockServer.stubFor(get(urlMatching(
365 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
366 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
367 .withStatus(HttpStatus.SC_NOT_FOUND)));
369 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
373 public void activateServiceInstanceNoRecipe() throws IOException {
374 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
375 Service defaultService = new Service();
376 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
377 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
378 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
379 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
381 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
382 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
384 ResponseEntity<String> response =
385 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
387 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
391 public void activateServiceInstance() throws IOException {
392 ServiceRecipe serviceRecipe = new ServiceRecipe();
393 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
394 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
395 serviceRecipe.setAction(Action.createInstance.toString());
396 serviceRecipe.setId(1);
397 serviceRecipe.setRecipeTimeout(180);
398 Service defaultService = new Service();
399 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
401 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
402 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
403 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
405 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
406 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
407 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
409 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
410 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
411 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
413 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
414 RequestReferences requestReferences = new RequestReferences();
415 requestReferences.setInstanceId("1882939");
416 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
417 expectedResponse.setRequestReferences(requestReferences);
418 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
419 ResponseEntity<String> response =
420 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
422 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
423 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
424 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
428 public void deactivateServiceInstance() throws IOException {
430 ServiceRecipe serviceRecipe = new ServiceRecipe();
431 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
432 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
433 serviceRecipe.setAction(Action.createInstance.toString());
434 serviceRecipe.setId(1);
435 serviceRecipe.setRecipeTimeout(180);
436 Service defaultService = new Service();
437 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
439 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
440 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
441 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
443 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
445 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
447 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
448 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
449 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
451 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
452 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
453 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
455 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
456 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
457 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
460 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
461 RequestReferences requestReferences = new RequestReferences();
462 requestReferences.setInstanceId("1882939");
463 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
464 expectedResponse.setRequestReferences(requestReferences);
465 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
466 ResponseEntity<String> response =
467 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
469 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
470 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
471 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
475 public void deleteServiceInstance() throws IOException {
476 ServiceRecipe serviceRecipe = new ServiceRecipe();
477 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
478 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
479 serviceRecipe.setAction(Action.createInstance.toString());
480 serviceRecipe.setId(1);
481 serviceRecipe.setRecipeTimeout(180);
482 Service defaultService = new Service();
483 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
485 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
487 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
489 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
490 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
491 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
493 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
495 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
497 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
498 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
499 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
501 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
502 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
503 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
505 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
506 RequestReferences requestReferences = new RequestReferences();
507 requestReferences.setInstanceId("1882939");
508 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
509 expectedResponse.setRequestReferences(requestReferences);
510 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
511 ResponseEntity<String> response =
512 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
514 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
515 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
516 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
520 public void assignServiceInstance() throws IOException {
521 ServiceRecipe serviceRecipe = new ServiceRecipe();
522 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
523 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
524 serviceRecipe.setAction(Action.createInstance.toString());
525 serviceRecipe.setId(1);
526 serviceRecipe.setRecipeTimeout(180);
527 Service defaultService = new Service();
528 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
530 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
531 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
532 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
534 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
535 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
536 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
538 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
539 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
540 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
542 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
543 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
544 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
546 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
547 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
548 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
550 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
551 RequestReferences requestReferences = new RequestReferences();
552 requestReferences.setInstanceId("1882939");
553 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
554 expectedResponse.setRequestReferences(requestReferences);
555 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
556 ResponseEntity<String> response =
557 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
559 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
560 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
561 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
565 public void unassignServiceInstance() throws IOException {
566 ServiceRecipe serviceRecipe = new ServiceRecipe();
567 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
568 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
569 serviceRecipe.setAction(Action.createInstance.toString());
570 serviceRecipe.setId(1);
571 serviceRecipe.setRecipeTimeout(180);
572 Service defaultService = new Service();
573 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
575 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
576 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
577 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
579 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
580 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
581 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
583 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
584 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
585 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
587 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
588 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
589 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
591 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
592 RequestReferences requestReferences = new RequestReferences();
593 requestReferences.setInstanceId("1882939");
594 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
595 expectedResponse.setRequestReferences(requestReferences);
596 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
597 ResponseEntity<String> response =
598 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
600 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
601 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
602 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
606 public void createPortConfiguration() throws IOException {
607 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
608 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
609 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
611 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
612 RequestReferences requestReferences = new RequestReferences();
613 requestReferences.setInstanceId("1882939");
614 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
615 expectedResponse.setRequestReferences(requestReferences);
616 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
617 ResponseEntity<String> response =
618 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
620 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
621 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
622 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
623 assertTrue(response.getBody().contains("1882939"));
627 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
628 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
629 ResponseEntity<String> response =
630 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
632 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
636 public void deletePortConfiguration() throws IOException {
637 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
638 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
639 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
642 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
643 RequestReferences requestReferences = new RequestReferences();
644 requestReferences.setInstanceId("1882939");
645 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
646 expectedResponse.setRequestReferences(requestReferences);
647 uri = servInstanceuri + "v7"
648 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
649 ResponseEntity<String> response =
650 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
652 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
653 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
654 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
658 public void enablePort() throws IOException {
659 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
660 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
661 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
663 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
664 RequestReferences requestReferences = new RequestReferences();
665 requestReferences.setInstanceId("1882939");
666 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
667 expectedResponse.setRequestReferences(requestReferences);
668 uri = servInstanceuri + "v7"
669 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
670 ResponseEntity<String> response =
671 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
673 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
674 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
675 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
679 public void disablePort() throws IOException {
680 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
681 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
682 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
684 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
685 RequestReferences requestReferences = new RequestReferences();
686 requestReferences.setInstanceId("1882939");
687 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
688 expectedResponse.setRequestReferences(requestReferences);
689 uri = servInstanceuri + "v7"
690 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
691 ResponseEntity<String> response =
692 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
694 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
695 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
696 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
700 public void activatePort() throws IOException {
701 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
702 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
703 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
705 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
706 RequestReferences requestReferences = new RequestReferences();
707 requestReferences.setInstanceId("1882939");
708 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
709 expectedResponse.setRequestReferences(requestReferences);
710 uri = servInstanceuri + "v7"
711 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
712 ResponseEntity<String> response =
713 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
715 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
716 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
717 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
721 public void deactivatePort() throws IOException {
722 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
723 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
724 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
726 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
727 RequestReferences requestReferences = new RequestReferences();
728 requestReferences.setInstanceId("1882939");
729 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
730 expectedResponse.setRequestReferences(requestReferences);
731 uri = servInstanceuri + "v7"
732 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
733 ResponseEntity<String> response =
734 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
736 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
737 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
738 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
742 public void addRelationships() throws IOException {
743 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
744 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
745 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
747 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
748 RequestReferences requestReferences = new RequestReferences();
749 requestReferences.setInstanceId("1882939");
750 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
751 expectedResponse.setRequestReferences(requestReferences);
752 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
753 ResponseEntity<String> response =
754 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
756 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
757 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
758 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
762 public void removeRelationships() throws IOException {
763 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
764 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
765 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
767 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
768 RequestReferences requestReferences = new RequestReferences();
769 requestReferences.setInstanceId("1882939");
770 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
771 expectedResponse.setRequestReferences(requestReferences);
772 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
773 ResponseEntity<String> response =
774 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
776 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
777 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
778 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
782 public void createVnfInstanceNoALaCarte() throws IOException {
783 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
784 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
785 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
788 wireMockServer.stubFor(get(urlMatching(
789 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
790 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
791 .withBody(getWiremockResponseForCatalogdb(
792 "vnfResourceCustomization_ReplaceVnf_Response.json"))
793 .withStatus(org.apache.http.HttpStatus.SC_OK)));
795 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
796 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
797 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
798 .withStatus(org.apache.http.HttpStatus.SC_OK)));
800 wireMockServer.stubFor(get(urlMatching(
801 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
802 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
803 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
804 .withStatus(org.apache.http.HttpStatus.SC_OK)));
807 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
808 RequestReferences requestReferences = new RequestReferences();
809 requestReferences.setInstanceId("1882939");
810 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
811 expectedResponse.setRequestReferences(requestReferences);
812 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
813 ResponseEntity<String> response =
814 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
816 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
817 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
818 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
822 public void createVnfInstance() throws IOException {
823 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
824 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
825 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
827 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
828 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
829 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
830 .withStatus(org.apache.http.HttpStatus.SC_OK)));
831 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
832 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
833 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
834 .withStatus(org.apache.http.HttpStatus.SC_OK)));
837 wireMockServer.stubFor(
838 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
839 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
840 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
841 .withStatus(org.apache.http.HttpStatus.SC_OK)));
843 wireMockServer.stubFor(get(urlMatching(
844 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
846 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
847 .withStatus(org.apache.http.HttpStatus.SC_OK)));
850 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
851 RequestReferences requestReferences = new RequestReferences();
852 requestReferences.setInstanceId("1882939");
853 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
854 expectedResponse.setRequestReferences(requestReferences);
855 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
856 ResponseEntity<String> response =
857 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
859 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
860 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
861 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
862 assertTrue(response.getBody().contains("1882939"));
866 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
867 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
868 ResponseEntity<String> response =
869 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
871 assertEquals(404, response.getStatusCode().value());
875 public void createVnfInstanceInvalidVnfResource() throws IOException {
876 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
877 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
879 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
880 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
881 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
885 public void replaceVnfInstance() throws IOException {
886 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
887 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
888 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
890 wireMockServer.stubFor(get(urlMatching(
891 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
892 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
893 .withBody(getWiremockResponseForCatalogdb(
894 "vnfResourceCustomization_ReplaceVnf_Response.json"))
895 .withStatus(org.apache.http.HttpStatus.SC_OK)));
897 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
898 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
899 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
900 .withStatus(org.apache.http.HttpStatus.SC_OK)));
902 wireMockServer.stubFor(get(urlMatching(
903 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
904 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
905 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
906 .withStatus(org.apache.http.HttpStatus.SC_OK)));
908 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
909 RequestReferences requestReferences = new RequestReferences();
910 requestReferences.setInstanceId("1882939");
911 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
912 expectedResponse.setRequestReferences(requestReferences);
913 uri = servInstanceuri + "v7"
914 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
915 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
917 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
918 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
919 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
923 public void replaceVnfInstanceNoCloudConfig() throws IOException {
924 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/v1/getInfraActiveRequests.*"))
925 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
926 .withBodyFile("infra/VnfLookup.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
927 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
928 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
929 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
930 wireMockServer.stubFor(get(urlMatching(
931 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
932 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
933 .withBody(getWiremockResponseForCatalogdb(
934 "vnfResourceCustomization_ReplaceVnf_Response.json"))
935 .withStatus(org.apache.http.HttpStatus.SC_OK)));
936 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
937 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
938 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
939 .withStatus(org.apache.http.HttpStatus.SC_OK)));
940 wireMockServer.stubFor(get(urlMatching(
941 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
942 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
943 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
944 .withStatus(org.apache.http.HttpStatus.SC_OK)));
946 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
947 RequestReferences requestReferences = new RequestReferences();
948 requestReferences.setInstanceId("1882939");
949 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
950 expectedResponse.setRequestReferences(requestReferences);
951 uri = servInstanceuri + "v7"
952 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
953 ResponseEntity<String> response =
954 sendRequest(inputStream("/ReplaceVnfNoCloudConfig.json"), uri, HttpMethod.POST, headers);
956 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
957 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
958 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
962 public void replaceVnfRecreateInstance() throws IOException {
963 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
964 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
965 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
967 wireMockServer.stubFor(get(urlMatching(
968 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
969 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
970 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
971 .withStatus(org.apache.http.HttpStatus.SC_OK)));
973 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
974 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
975 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
976 .withStatus(org.apache.http.HttpStatus.SC_OK)));
978 wireMockServer.stubFor(get(urlMatching(
979 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
980 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
981 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
982 .withStatus(org.apache.http.HttpStatus.SC_OK)));
985 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
986 RequestReferences requestReferences = new RequestReferences();
987 requestReferences.setInstanceId("1882939");
988 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
989 expectedResponse.setRequestReferences(requestReferences);
990 uri = servInstanceuri + "v7"
991 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
992 ResponseEntity<String> response =
993 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
994 logger.debug(response.getBody());
996 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
997 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
998 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1002 public void recreateVnfInstance() throws IOException {
1003 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1004 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1005 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1007 wireMockServer.stubFor(get(urlMatching(
1008 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1009 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1010 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
1011 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1013 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1014 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1015 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1016 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1018 wireMockServer.stubFor(get(urlMatching(
1019 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1020 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1021 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1022 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1024 // expected response
1025 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1026 RequestReferences requestReferences = new RequestReferences();
1027 requestReferences.setInstanceId("1882939");
1028 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1029 expectedResponse.setRequestReferences(requestReferences);
1030 uri = servInstanceuri + "v7"
1031 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1032 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1033 logger.debug(response.getBody());
1035 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1036 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1037 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1041 public void updateVnfInstance() throws IOException {
1042 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1043 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1044 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1046 wireMockServer.stubFor(get(urlMatching(
1047 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1048 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1049 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1050 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1052 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1053 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1054 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1055 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1057 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1058 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1059 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1060 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1061 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1063 // expected response
1064 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1065 RequestReferences requestReferences = new RequestReferences();
1066 requestReferences.setInstanceId("1882939");
1067 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1068 expectedResponse.setRequestReferences(requestReferences);
1069 uri = servInstanceuri + "v7"
1070 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1071 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1073 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1074 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1075 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1079 public void applyUpdatedConfig() throws IOException {
1080 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1081 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1082 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1085 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1086 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1087 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1088 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1089 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1091 // expected response
1092 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1093 RequestReferences requestReferences = new RequestReferences();
1094 requestReferences.setInstanceId("1882939");
1095 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1096 expectedResponse.setRequestReferences(requestReferences);
1097 uri = servInstanceuri + "v7"
1098 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1099 ResponseEntity<String> response =
1100 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1102 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1103 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1104 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1108 public void deleteVnfInstanceV5() throws IOException {
1109 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1110 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1111 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1113 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1114 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1115 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1116 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1117 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1118 // expected response
1119 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1120 RequestReferences requestReferences = new RequestReferences();
1121 requestReferences.setInstanceId("1882939");
1122 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1123 expectedResponse.setRequestReferences(requestReferences);
1124 uri = servInstanceuri + "v5"
1125 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1126 ResponseEntity<String> response =
1127 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1129 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1130 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1131 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1135 public void createVfModuleInstance() throws IOException {
1136 wireMockServer.stubFor(get(urlMatching(
1137 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1138 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1139 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1140 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1142 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1143 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1144 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1145 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1147 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1148 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1149 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1150 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1152 wireMockServer.stubFor(get(urlMatching(
1153 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1154 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1155 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1156 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1158 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1159 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1160 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1162 wireMockServer.stubFor(get(urlMatching(
1163 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1164 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1165 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1166 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1167 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1168 // expected response
1169 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1170 RequestReferences requestReferences = new RequestReferences();
1171 requestReferences.setInstanceId("1882939");
1172 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1173 expectedResponse.setRequestReferences(requestReferences);
1174 uri = servInstanceuri + "v7"
1175 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1176 ResponseEntity<String> response =
1177 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1179 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1180 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1181 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1182 assertTrue(response.getBody().contains("1882939"));
1186 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1187 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1188 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1189 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1191 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1192 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1193 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1194 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1197 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1198 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1199 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1200 .withBody(getWiremockResponseForCatalogdb(
1201 "vnfResourceCustomizationForVfModule_Response.json"))
1202 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1204 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1205 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1206 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1207 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1209 wireMockServer.stubFor(get(urlMatching(
1210 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1211 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1212 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1213 .withBody(getWiremockResponseForCatalogdb(
1214 "vfModuleCustomizationPCM_Response.json"))
1215 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1217 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1218 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1219 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1220 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1222 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1223 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1224 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1225 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1228 wireMockServer.stubFor(
1229 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1230 + "[?]vnfComponentType=vfModule&action=createInstance"))
1231 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1232 .withBody(getWiremockResponseForCatalogdb(
1233 "vnfComponentRecipeVNF_API_Response.json"))
1234 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1236 // expected response
1237 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1238 RequestReferences requestReferences = new RequestReferences();
1239 requestReferences.setInstanceId("1882939");
1240 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1241 expectedResponse.setRequestReferences(requestReferences);
1242 uri = servInstanceuri + "v6"
1243 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1244 ResponseEntity<String> response =
1245 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1246 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1247 ObjectMapper mapper = new ObjectMapper();
1248 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1249 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1253 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1254 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1255 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1256 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1258 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1259 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1260 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1261 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1264 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1265 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1266 .withBody(getWiremockResponseForCatalogdb(
1267 "vnfResourceCustomizationForVfModule_Response.json"))
1268 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1270 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1272 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1273 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1275 wireMockServer.stubFor(get(urlMatching(
1276 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1277 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1278 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1279 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1281 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1282 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1283 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1284 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1286 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1287 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1288 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1289 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1291 wireMockServer.stubFor(get(urlMatching(
1292 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1293 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1294 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1295 .withBody(getWiremockResponseForCatalogdb(
1296 "vnfComponentRecipeDeleteVfModule_Response.json"))
1297 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1299 // expected response
1300 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1301 RequestReferences requestReferences = new RequestReferences();
1302 requestReferences.setInstanceId("1882939");
1303 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1304 expectedResponse.setRequestReferences(requestReferences);
1305 uri = servInstanceuri + "v6"
1306 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1307 ResponseEntity<String> response =
1308 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1311 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1312 ObjectMapper mapper = new ObjectMapper();
1313 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1314 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1318 public void createVfModuleInstanceNoRecipe() throws IOException {
1320 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1321 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1322 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1323 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1326 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1327 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1328 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1329 .withBody(getWiremockResponseForCatalogdb(
1330 "vnfResourceCustomizationForVfModule_Response.json"))
1331 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1333 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1335 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1336 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1338 wireMockServer.stubFor(
1339 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1340 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1341 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1342 .withBody(getWiremockResponseForCatalogdb(
1343 "vfModuleCustomizationPCM_Response.json"))
1344 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1346 uri = servInstanceuri + "v6"
1347 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1348 ResponseEntity<String> response =
1349 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1351 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1352 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1353 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1357 public void replaceVfModuleInstance() throws IOException {
1358 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1359 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1360 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1363 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1364 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1365 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1366 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1367 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1369 wireMockServer.stubFor(get(urlMatching(
1370 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1371 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1372 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1373 .withBody(getWiremockResponseForCatalogdb(
1374 "vnfComponentRecipeDeleteVfModule_Response.json"))
1375 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1376 // expected response
1377 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1378 RequestReferences requestReferences = new RequestReferences();
1379 requestReferences.setInstanceId("1882939");
1380 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1381 expectedResponse.setRequestReferences(requestReferences);
1382 uri = servInstanceuri + "v7"
1383 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1384 ResponseEntity<String> response =
1385 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1387 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1388 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1389 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1393 public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException {
1394 wireMockServer.stubFor(
1395 get(urlPathMatching("/aai/v\\d+/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000"))
1396 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1397 .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1398 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1400 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1402 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1403 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1404 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1405 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1406 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1407 wireMockServer.stubFor(get(urlMatching(
1408 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1409 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1410 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1411 .withBody(getWiremockResponseForCatalogdb(
1412 "vnfComponentRecipeDeleteVfModule_Response.json"))
1413 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1414 // expected response
1415 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1416 RequestReferences requestReferences = new RequestReferences();
1417 requestReferences.setInstanceId("1882939");
1418 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1419 expectedResponse.setRequestReferences(requestReferences);
1420 uri = servInstanceuri + "v7"
1421 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1422 ResponseEntity<String> response =
1423 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
1425 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1426 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1427 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1431 public void updateVfModuleInstance() throws IOException {
1432 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1433 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1434 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1436 wireMockServer.stubFor(get(urlMatching(
1437 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1438 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1439 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1440 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1442 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1443 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1444 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1445 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1447 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1448 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1449 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1450 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1452 wireMockServer.stubFor(get(urlMatching(
1453 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1454 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1455 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1456 .withBody(getWiremockResponseForCatalogdb(
1457 "vnfComponentRecipe_GRAPI_Response.json"))
1458 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1460 // expected response
1461 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1462 RequestReferences requestReferences = new RequestReferences();
1463 requestReferences.setInstanceId("1882939");
1464 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1465 expectedResponse.setRequestReferences(requestReferences);
1466 uri = servInstanceuri + "v7"
1467 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1468 ResponseEntity<String> response =
1469 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1470 logger.debug(response.getBody());
1472 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1473 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1474 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1478 public void createVfModuleNoModelType() throws IOException {
1479 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1480 expectedRecord.setRequestStatus("FAILED");
1481 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1482 expectedRecord.setProgress(100L);
1483 expectedRecord.setSource("VID");
1484 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1485 expectedRecord.setLastModifiedBy("APIH");
1486 expectedRecord.setVfModuleName("testVfModule2");
1487 expectedRecord.setVfModuleModelName("serviceModel");
1488 expectedRecord.setRequestScope("vfModule");
1489 expectedRecord.setRequestAction("createInstance");
1490 expectedRecord.setRequestorId("zz9999");
1491 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1492 // VnfType is not sent in this request, should be blank in db
1493 expectedRecord.setVnfType("");
1494 uri = servInstanceuri
1495 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1497 ResponseEntity<String> response =
1498 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1500 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1504 public void inPlaceSoftwareUpdate() throws IOException {
1505 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1507 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1509 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1510 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1511 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1512 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1513 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1515 // expected response
1516 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1517 RequestReferences requestReferences = new RequestReferences();
1518 requestReferences.setInstanceId("1882939");
1519 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1520 expectedResponse.setRequestReferences(requestReferences);
1521 uri = servInstanceuri + "v7"
1522 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1523 ResponseEntity<String> response =
1524 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1526 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1527 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1528 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1532 public void deleteVfModuleInstance() throws IOException {
1533 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1534 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1535 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1538 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1539 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1540 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1541 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1542 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1544 wireMockServer.stubFor(get(urlMatching(
1545 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1546 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1547 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1548 .withBody(getWiremockResponseForCatalogdb(
1549 "vnfComponentRecipeDeleteVfModule_Response.json"))
1550 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1552 // expected response
1553 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1554 RequestReferences requestReferences = new RequestReferences();
1555 requestReferences.setInstanceId("1882939");
1556 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1557 expectedResponse.setRequestReferences(requestReferences);
1558 uri = servInstanceuri + "v7"
1559 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1560 ResponseEntity<String> response =
1561 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1563 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1564 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1565 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1569 public void deleteVfModuleNoModelInvariantId() throws IOException {
1570 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1571 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1572 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1574 wireMockServer.stubFor(get(urlMatching(
1575 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1576 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1577 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1578 .withBody(getWiremockResponseForCatalogdb(
1579 "vnfComponentRecipeDeleteVfModule_Response.json"))
1580 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1582 // expected response
1583 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1584 RequestReferences requestReferences = new RequestReferences();
1585 requestReferences.setInstanceId("1882939");
1586 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1587 expectedResponse.setRequestReferences(requestReferences);
1588 uri = servInstanceuri + "v7"
1589 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1590 ResponseEntity<String> response =
1591 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1593 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1594 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1595 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1599 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1600 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1601 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1602 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1605 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1606 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1607 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1608 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1609 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1611 wireMockServer.stubFor(get(urlMatching(
1612 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1613 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1614 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1615 .withBody(getWiremockResponseForCatalogdb(
1616 "vnfComponentRecipeDeactivate_Response.json"))
1617 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1619 // expected response
1620 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1621 RequestReferences requestReferences = new RequestReferences();
1622 requestReferences.setInstanceId("1882939");
1623 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1624 expectedResponse.setRequestReferences(requestReferences);
1625 uri = servInstanceuri + "v7"
1626 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1627 ResponseEntity<String> response =
1628 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1630 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1631 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1632 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1636 public void createVolumeGroupInstance() throws IOException {
1637 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1638 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1639 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1641 wireMockServer.stubFor(get(urlMatching(
1642 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1643 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1644 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1645 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1647 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1648 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1649 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1650 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1652 wireMockServer.stubFor(get(urlMatching(
1653 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1654 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1656 .withBody(getWiremockResponseForCatalogdb(
1657 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1658 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1660 // expected response
1661 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1662 RequestReferences requestReferences = new RequestReferences();
1663 requestReferences.setInstanceId("1882939");
1664 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1665 expectedResponse.setRequestReferences(requestReferences);
1666 uri = servInstanceuri + "v7"
1667 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1668 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1670 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1671 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1672 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1673 assertTrue(response.getBody().contains("1882939"));
1677 public void updateVolumeGroupInstance() throws IOException {
1678 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1679 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1680 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1682 wireMockServer.stubFor(get(urlMatching(
1683 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1684 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1685 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1686 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1688 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1689 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1690 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1691 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1693 wireMockServer.stubFor(get(urlMatching(
1694 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1695 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1696 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1697 .withBody(getWiremockResponseForCatalogdb(
1698 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1699 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1701 // expected response
1702 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1703 RequestReferences requestReferences = new RequestReferences();
1704 requestReferences.setInstanceId("1882939");
1705 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1706 expectedResponse.setRequestReferences(requestReferences);
1707 uri = servInstanceuri + "v7"
1708 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1709 ResponseEntity<String> response =
1710 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1712 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1713 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1714 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1718 public void deleteVolumeGroupInstance() throws IOException {
1719 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1720 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1721 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1723 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1724 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1725 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1727 wireMockServer.stubFor(get(urlMatching(
1728 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1729 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1730 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1731 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1733 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1734 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1735 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1736 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1738 wireMockServer.stubFor(get(urlMatching(
1739 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1740 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1741 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1742 .withBody(getWiremockResponseForCatalogdb(
1743 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1744 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1746 // expected response
1747 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1748 RequestReferences requestReferences = new RequestReferences();
1749 requestReferences.setInstanceId("1882939");
1750 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1751 expectedResponse.setRequestReferences(requestReferences);
1752 uri = servInstanceuri + "v7"
1753 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1754 ResponseEntity<String> response =
1755 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1757 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1758 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1759 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1763 public void createNetworkInstance() throws IOException {
1764 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1765 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1766 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1768 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1769 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1770 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1771 .withStatus(HttpStatus.SC_OK)));
1773 wireMockServer.stubFor(
1774 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1775 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1776 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1777 .withStatus(HttpStatus.SC_OK)));
1779 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1780 + "modelName=GR-API-DEFAULT&action=createInstance"))
1781 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1782 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1783 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1785 // expected response
1786 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1787 RequestReferences requestReferences = new RequestReferences();
1788 requestReferences.setInstanceId("1882939");
1789 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1790 expectedResponse.setRequestReferences(requestReferences);
1791 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1792 ResponseEntity<String> response =
1793 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1795 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1796 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1797 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1801 public void updateNetworkInstance() throws IOException {
1802 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1803 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1804 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1806 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1807 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1808 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1809 .withStatus(HttpStatus.SC_OK)));
1811 wireMockServer.stubFor(
1812 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1813 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1814 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1815 .withStatus(HttpStatus.SC_OK)));
1817 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1818 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1819 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1820 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1821 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1822 // expected response
1823 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1824 RequestReferences requestReferences = new RequestReferences();
1825 requestReferences.setInstanceId("1882939");
1826 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1827 expectedResponse.setRequestReferences(requestReferences);
1828 uri = servInstanceuri + "v7"
1829 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1830 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1832 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1833 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1834 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1835 assertTrue(response.getBody().contains("1882939"));
1839 public void deleteNetworkInstance() throws IOException {
1840 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1841 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1842 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1844 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1846 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1847 .withStatus(HttpStatus.SC_OK)));
1849 wireMockServer.stubFor(
1850 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1851 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1852 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1853 .withStatus(HttpStatus.SC_OK)));
1855 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1856 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1857 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1858 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1859 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1861 // expected response
1862 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1863 RequestReferences requestReferences = new RequestReferences();
1864 requestReferences.setInstanceId("1882939");
1865 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1866 expectedResponse.setRequestReferences(requestReferences);
1867 uri = servInstanceuri + "v7"
1868 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1869 ResponseEntity<String> response =
1870 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1872 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1873 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1874 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1878 public void deleteNetworkInstanceNoReqParams() throws IOException {
1879 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1880 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1881 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1883 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1884 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1885 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1886 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1887 .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("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1895 expectedResponse.setRequestReferences(requestReferences);
1896 uri = servInstanceuri + "v6"
1897 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1898 ResponseEntity<String> response =
1899 sendRequest(inputStream("/NetworkInstanceNoReqParams.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 convertJsonToServiceInstanceRequestFail() throws IOException {
1909 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1910 expectedRecord.setRequestStatus("FAILED");
1911 expectedRecord.setStatusMessage("Error mapping request: ");
1912 expectedRecord.setProgress(100L);
1913 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1914 expectedRecord.setLastModifiedBy("APIH");
1915 expectedRecord.setRequestScope("network");
1916 expectedRecord.setRequestAction("deleteInstance");
1917 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1919 uri = servInstanceuri + "v6"
1920 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1921 ResponseEntity<String> response =
1922 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1926 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1930 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1931 uri = servInstanceuri + "v5"
1932 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1933 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1935 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1939 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1940 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1941 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1942 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1944 ServiceRecipe serviceRecipe = new ServiceRecipe();
1945 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1946 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1947 serviceRecipe.setAction(Action.createInstance.toString());
1948 serviceRecipe.setId(1);
1949 serviceRecipe.setRecipeTimeout(180);
1950 Service defaultService = new Service();
1951 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1953 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1954 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1955 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1957 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
1958 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1959 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
1961 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1962 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1963 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1965 uri = servInstanceuri + "v7" + "/serviceInstances";
1966 ResponseEntity<String> response =
1967 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1969 // expected response
1970 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1971 RequestReferences requestReferences = new RequestReferences();
1972 requestReferences.setInstanceId("1882939");
1973 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1974 expectedResponse.setRequestReferences(requestReferences);
1976 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1977 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1978 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1982 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1983 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1984 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1985 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1987 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1988 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1989 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1990 .withStatus(HttpStatus.SC_OK)));
1992 wireMockServer.stubFor(
1993 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1994 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1995 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1996 .withStatus(HttpStatus.SC_OK)));
1998 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1999 + "modelName=GR-API-DEFAULT&action=createInstance"))
2000 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2001 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2002 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2004 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2005 ResponseEntity<String> response =
2006 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
2008 // expected response
2009 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2010 RequestReferences requestReferences = new RequestReferences();
2011 requestReferences.setInstanceId("1882939");
2012 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2013 expectedResponse.setRequestReferences(requestReferences);
2015 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2016 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2017 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2021 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
2022 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2023 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2024 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2026 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2027 ResponseEntity<String> response =
2028 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
2030 // expected response
2031 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2032 RequestReferences requestReferences = new RequestReferences();
2033 requestReferences.setInstanceId("1882939");
2034 expectedResponse.setRequestReferences(requestReferences);
2036 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2040 public void createNetworkInstanceTestApiGrApi() throws IOException {
2041 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2042 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2043 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2045 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2046 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2047 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2048 .withStatus(HttpStatus.SC_OK)));
2050 wireMockServer.stubFor(
2051 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2052 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2053 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2054 .withStatus(HttpStatus.SC_OK)));
2056 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2057 + "modelName=GR-API-DEFAULT&action=createInstance"))
2058 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2059 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2060 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2062 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2063 ResponseEntity<String> response =
2064 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2066 // expected response
2067 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2068 RequestReferences requestReferences = new RequestReferences();
2069 requestReferences.setInstanceId("1882939");
2070 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2071 expectedResponse.setRequestReferences(requestReferences);
2073 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2074 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2075 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2079 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2080 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2081 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2082 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2084 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2085 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2086 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2087 .withStatus(HttpStatus.SC_OK)));
2089 wireMockServer.stubFor(
2090 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2091 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2092 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2093 .withStatus(HttpStatus.SC_OK)));
2095 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2096 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2097 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2098 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2099 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2101 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2102 ResponseEntity<String> response =
2103 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2105 // expected response
2106 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2107 RequestReferences requestReferences = new RequestReferences();
2108 requestReferences.setInstanceId("1882939");
2109 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2110 expectedResponse.setRequestReferences(requestReferences);
2112 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2113 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2114 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2118 public void activateServiceInstanceRequestStatus() throws IOException {
2119 ServiceRecipe serviceRecipe = new ServiceRecipe();
2120 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2121 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2122 serviceRecipe.setAction(Action.createInstance.toString());
2123 serviceRecipe.setId(1);
2124 serviceRecipe.setRecipeTimeout(180);
2125 Service defaultService = new Service();
2126 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2128 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2129 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2130 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2132 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2133 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2134 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2136 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
2137 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2138 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
2140 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2141 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2142 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2145 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2146 RequestReferences requestReferences = new RequestReferences();
2147 requestReferences.setInstanceId("1882939");
2148 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2149 expectedResponse.setRequestReferences(requestReferences);
2150 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2151 ResponseEntity<String> response =
2152 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2154 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2155 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2156 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2160 public void invalidRequestId() throws IOException {
2161 String illegalRequestId = "1234";
2162 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2163 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2164 uri = servInstanceuri + "v5/serviceInstances";
2165 ResponseEntity<String> response =
2166 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2168 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2169 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2173 public void invalidBPELResponse() throws IOException {
2175 ServiceRecipe serviceRecipe = new ServiceRecipe();
2176 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2177 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2178 serviceRecipe.setAction(Action.createInstance.toString());
2179 serviceRecipe.setId(1);
2180 serviceRecipe.setRecipeTimeout(180);
2181 Service defaultService = new Service();
2182 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2184 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2185 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2186 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2188 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2189 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2190 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2192 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2193 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2194 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2196 uri = servInstanceuri + "v5/serviceInstances";
2197 ResponseEntity<String> response =
2198 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2200 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2201 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2202 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2203 realResponse.getServiceException().getText());
2207 public void unauthorizedBPELResponse() throws IOException {
2209 ServiceRecipe serviceRecipe = new ServiceRecipe();
2210 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2211 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2212 serviceRecipe.setAction(Action.createInstance.toString());
2213 serviceRecipe.setId(1);
2214 serviceRecipe.setRecipeTimeout(180);
2215 Service defaultService = new Service();
2216 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2218 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2219 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2220 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2222 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2223 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2224 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2226 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2227 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2228 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2230 uri = servInstanceuri + "v5/serviceInstances";
2231 ResponseEntity<String> response =
2232 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2234 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2235 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2236 assertEquals("Request Failed due to BPEL error with HTTP Status = 401 UNAUTHORIZED",
2237 realResponse.getServiceException().getText());
2241 public void invalidBPELResponse2() throws IOException {
2243 ServiceRecipe serviceRecipe = new ServiceRecipe();
2244 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2245 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2246 serviceRecipe.setAction(Action.createInstance.toString());
2247 serviceRecipe.setId(1);
2248 serviceRecipe.setRecipeTimeout(180);
2249 Service defaultService = new Service();
2250 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2252 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2253 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2254 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2256 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2257 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2258 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2260 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2261 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2262 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2263 uri = servInstanceuri + "v5/serviceInstances";
2264 ResponseEntity<String> response =
2265 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2267 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2268 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2269 assertTrue(realResponse.getServiceException().getText()
2270 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2274 public void createMacroServiceInstance() throws IOException {
2275 ServiceRecipe serviceRecipe = new ServiceRecipe();
2276 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2277 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2278 serviceRecipe.setAction(Action.createInstance.toString());
2279 serviceRecipe.setId(1);
2280 serviceRecipe.setRecipeTimeout(180);
2281 Service defaultService = new Service();
2282 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2284 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2286 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2288 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2289 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2290 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2292 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2293 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2294 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2296 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2297 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2298 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2301 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2302 RequestReferences requestReferences = new RequestReferences();
2303 requestReferences.setInstanceId("1882939");
2304 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2305 expectedResponse.setRequestReferences(requestReferences);
2306 uri = servInstanceuri + "v5";
2307 ResponseEntity<String> response =
2308 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2311 assertEquals(404, response.getStatusCode().value());
2315 public void testUserParams() throws IOException {
2316 ObjectMapper mapper = new ObjectMapper();
2317 ServiceInstancesRequest request =
2318 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2319 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2320 String userParamsTxt = inputStream("/userParams.txt");
2322 List<Map<String, Object>> userParams = requestHandlerUtils.configureUserParams(requestParameters);
2323 System.out.println(userParams);
2324 assertTrue(userParams.size() > 0);
2325 assertTrue(userParams.get(0).containsKey("name"));
2326 assertTrue(userParams.get(0).containsKey("value"));
2327 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2331 public void testConfigureCloudConfig() throws IOException {
2332 ObjectMapper mapper = new ObjectMapper();
2333 ServiceInstancesRequest request =
2334 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2335 CloudConfiguration cloudConfig =
2336 requestHandlerUtils.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2338 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2339 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2343 public void testMapToLegacyRequest() throws IOException {
2344 ObjectMapper mapper = new ObjectMapper();
2345 ServiceInstancesRequest request =
2346 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2347 ServiceInstancesRequest expected =
2348 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2349 requestHandlerUtils.mapToLegacyRequest(request.getRequestDetails());
2350 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2351 assertThat(request, sameBeanAs(expected));
2355 public void scaleOutVfModule() throws IOException {
2356 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2357 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2358 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2360 wireMockServer.stubFor(get(urlMatching(
2361 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2362 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2363 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2364 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2366 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2367 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2368 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2369 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2371 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2372 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2373 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2374 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2377 wireMockServer.stubFor(get(urlMatching(
2378 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2379 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2380 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2381 .withBody(getWiremockResponseForCatalogdb(
2382 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2383 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2385 wireMockServer.stubFor(get(urlMatching(
2386 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2387 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2388 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2389 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2391 // expected response
2392 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2393 RequestReferences requestReferences = new RequestReferences();
2394 requestReferences.setInstanceId("1882939");
2395 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2396 expectedResponse.setRequestReferences(requestReferences);
2397 uri = servInstanceuri + "v7"
2398 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2399 ResponseEntity<String> response =
2400 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2402 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2403 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2404 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2405 assertTrue(response.getBody().contains("1882939"));
2409 public void createServiceInstanceBadResponse() throws IOException {
2410 ServiceRecipe serviceRecipe = new ServiceRecipe();
2411 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2412 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2413 serviceRecipe.setAction(Action.createInstance.toString());
2414 serviceRecipe.setId(1);
2415 serviceRecipe.setRecipeTimeout(180);
2416 Service defaultService = new Service();
2417 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2419 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2420 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2421 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2423 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2424 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2425 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2427 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2428 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2429 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2431 uri = servInstanceuri + "v5/serviceInstances";
2432 ResponseEntity<String> response =
2433 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2435 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2436 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2437 assertEquals("Exception caught mapping Camunda JSON response to object",
2438 realResponse.getServiceException().getText());
2442 public void createServiceInstanceDuplicateError() throws IOException {
2443 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2445 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2447 uri = servInstanceuri + "v5/serviceInstances";
2448 ResponseEntity<String> response =
2449 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2451 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2452 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2454 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2455 realResponse.getServiceException().getText());
2459 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2460 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2461 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2462 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2463 .withStatus(HttpStatus.SC_ACCEPTED)));
2464 wireMockServer.stubFor(get(
2465 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2466 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2467 .withBodyFile("Camunda/HistoryCheckResponse.json")
2468 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2470 uri = servInstanceuri + "v5/serviceInstances";
2471 ResponseEntity<String> response =
2472 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2474 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2475 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2477 "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.",
2478 realResponse.getServiceException().getText());
2482 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2483 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2484 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2485 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2486 .withStatus(HttpStatus.SC_ACCEPTED)));
2487 wireMockServer.stubFor(get(
2488 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2489 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2490 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2492 uri = servInstanceuri + "v5/serviceInstances";
2493 ResponseEntity<String> response =
2494 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2496 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2497 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2499 "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",
2500 realResponse.getServiceException().getText());
2504 public void createServiceInstanceDuplicate() throws IOException {
2505 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2507 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2509 uri = servInstanceuri + "v5/serviceInstances";
2510 ResponseEntity<String> response =
2511 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2513 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2514 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2516 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2517 realResponse.getServiceException().getText());
2521 public void createServiceInstanceSaveError() throws IOException {
2522 ServiceRecipe serviceRecipe = new ServiceRecipe();
2523 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2524 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2525 serviceRecipe.setAction(Action.createInstance.toString());
2526 serviceRecipe.setId(1);
2527 serviceRecipe.setRecipeTimeout(180);
2528 Service defaultService = new Service();
2529 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2530 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2531 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2532 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2533 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2534 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2535 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2537 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2538 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2539 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2541 uri = servInstanceuri + "v5/serviceInstances";
2542 ResponseEntity<String> response =
2543 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2545 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2546 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2548 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2549 realResponse.getServiceException().getText());
2553 public void createPortConfigurationSaveError() throws IOException {
2554 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2555 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2556 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2557 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2558 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2559 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2561 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2562 ResponseEntity<String> response =
2563 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2565 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2566 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2568 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2569 realResponse.getServiceException().getText());
2573 public void createPortConfigDbUpdateError() throws IOException {
2574 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2575 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2576 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2578 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2579 ResponseEntity<String> response =
2580 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2582 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2583 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2585 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2586 realResponse.getServiceException().getText());
2590 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2591 TestAppender.events.clear();
2592 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2593 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2594 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2596 wireMockServer.stubFor(get(urlMatching(
2597 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2598 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2599 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2600 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2602 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2604 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2605 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2607 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2608 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2609 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2610 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2611 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2612 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2614 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2615 RequestReferences requestReferences = new RequestReferences();
2616 requestReferences.setInstanceId("1882939");
2617 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2618 expectedResponse.setRequestReferences(requestReferences);
2619 uri = servInstanceuri
2620 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2621 ResponseEntity<String> response =
2622 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2624 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2625 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2626 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2627 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2631 public void createInstanceGroup() throws IOException {
2632 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2633 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2634 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2637 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2638 RequestReferences requestReferences = new RequestReferences();
2639 requestReferences.setInstanceId("1882939");
2640 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2641 expectedResponse.setRequestReferences(requestReferences);
2642 uri = servInstanceuri + "/v7/instanceGroups";
2643 ResponseEntity<String> response =
2644 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2647 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2648 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2649 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2653 public void deleteInstanceGroup() throws IOException {
2654 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2656 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2659 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2660 RequestReferences requestReferences = new RequestReferences();
2661 requestReferences.setInstanceId("1882939");
2662 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2663 expectedResponse.setRequestReferences(requestReferences);
2664 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2665 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2668 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2669 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2670 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2674 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2675 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2676 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2678 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2679 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2680 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2684 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2685 HttpHeaders noPartnerHeaders = new HttpHeaders();
2686 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2687 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2688 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2689 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2691 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2692 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2693 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2697 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2698 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2699 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2700 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2702 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2703 RequestReferences requestReferences = new RequestReferences();
2704 requestReferences.setInstanceId("1882939");
2705 expectedResponse.setRequestReferences(requestReferences);
2706 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2707 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2710 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2711 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2712 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2716 public void addMembers() throws IOException {
2717 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2718 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2719 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2721 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2722 RequestReferences requestReferences = new RequestReferences();
2723 requestReferences.setInstanceId("1882939");
2724 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2725 expectedResponse.setRequestReferences(requestReferences);
2726 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2727 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2730 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2731 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2732 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2736 public void removeMembers() throws IOException {
2737 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2738 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2739 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2741 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2742 RequestReferences requestReferences = new RequestReferences();
2743 requestReferences.setInstanceId("1882939");
2744 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2745 expectedResponse.setRequestReferences(requestReferences);
2746 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2747 ResponseEntity<String> response =
2748 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2751 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2752 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2753 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2757 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2758 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2759 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2760 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2762 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2763 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2764 .withStatus(HttpStatus.SC_NOT_FOUND)));
2766 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2767 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2768 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2769 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2770 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2772 // expected response
2773 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2774 RequestReferences requestReferences = new RequestReferences();
2775 requestReferences.setInstanceId("1882939");
2776 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2777 expectedResponse.setRequestReferences(requestReferences);
2778 uri = servInstanceuri + "v7"
2779 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2780 ResponseEntity<String> response =
2781 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2783 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2784 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2785 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2789 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2790 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2791 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2792 .withStatus(HttpStatus.SC_NOT_FOUND)));
2794 uri = servInstanceuri + "v7"
2795 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2796 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2798 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2799 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2800 assertEquals(realResponse.getServiceException().getText(),
2801 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2805 public void setServiceTypeTestALaCarte() throws JsonProcessingException {
2806 String requestScope = ModelType.service.toString();
2807 Boolean aLaCarteFlag = true;
2808 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2809 RequestDetails requestDetails = new RequestDetails();
2810 RequestInfo requestInfo = new RequestInfo();
2811 requestInfo.setSource("VID");
2812 requestDetails.setRequestInfo(requestInfo);
2813 sir.setRequestDetails(requestDetails);
2814 Service defaultService = new Service();
2815 defaultService.setServiceType("testServiceTypeALaCarte");
2817 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2818 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2819 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2821 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2822 assertEquals(serviceType, "testServiceTypeALaCarte");
2826 public void setServiceTypeTest() throws JsonProcessingException {
2827 String requestScope = ModelType.service.toString();
2828 Boolean aLaCarteFlag = false;
2829 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2830 RequestDetails requestDetails = new RequestDetails();
2831 RequestInfo requestInfo = new RequestInfo();
2832 ModelInfo modelInfo = new ModelInfo();
2833 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2834 requestInfo.setSource("VID");
2835 requestDetails.setModelInfo(modelInfo);
2836 requestDetails.setRequestInfo(requestInfo);
2837 sir.setRequestDetails(requestDetails);
2838 Service defaultService = new Service();
2839 defaultService.setServiceType("testServiceType");
2841 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2842 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2843 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2845 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2846 assertEquals(serviceType, "testServiceType");
2850 public void setServiceTypeTestDefault() throws JsonProcessingException {
2851 String requestScope = ModelType.service.toString();
2852 Boolean aLaCarteFlag = false;
2853 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2854 RequestDetails requestDetails = new RequestDetails();
2855 RequestInfo requestInfo = new RequestInfo();
2856 ModelInfo modelInfo = new ModelInfo();
2857 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2858 requestInfo.setSource("VID");
2859 requestDetails.setModelInfo(modelInfo);
2860 requestDetails.setRequestInfo(requestInfo);
2861 sir.setRequestDetails(requestDetails);
2862 Service defaultService = new Service();
2863 defaultService.setServiceType("testServiceType");
2865 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2866 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2867 .withStatus(HttpStatus.SC_NOT_FOUND)));
2868 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2869 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2870 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2872 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2873 assertEquals(serviceType, "testServiceType");
2877 public void setServiceTypeTestNetwork() throws JsonProcessingException {
2878 String requestScope = ModelType.network.toString();
2879 Boolean aLaCarteFlag = null;
2880 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2881 RequestDetails requestDetails = new RequestDetails();
2882 RequestInfo requestInfo = new RequestInfo();
2883 ModelInfo modelInfo = new ModelInfo();
2884 modelInfo.setModelName("networkModelName");
2885 requestInfo.setSource("VID");
2886 requestDetails.setModelInfo(modelInfo);
2887 requestDetails.setRequestInfo(requestInfo);
2888 sir.setRequestDetails(requestDetails);
2890 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2891 assertEquals(serviceType, "networkModelName");
2895 public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
2896 String requestScope = "instanceGroup";
2897 ServiceInstancesRequest sir =
2898 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
2899 assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
2900 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2904 public void setServiceInstanceIdTest() {
2905 String requestScope = "vnf";
2906 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2907 sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2908 assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
2909 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2913 public void setServiceInstanceIdReturnNullTest() {
2914 String requestScope = "vnf";
2915 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2916 assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2920 public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
2921 wireMockServer.stubFor(get(
2922 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2923 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2924 .withBodyFile("Camunda/HistoryCheckResponse.json")
2925 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2927 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2928 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2929 boolean inProgress = false;
2930 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2931 assertTrue(inProgress);
2935 public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
2936 wireMockServer.stubFor(get(
2937 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2938 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2939 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
2941 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2942 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2943 boolean inProgress = false;
2944 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2945 assertFalse(inProgress);
2949 public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
2950 String replaceVfModule = inputStream("/ReplaceVfModule.json");
2951 ObjectMapper mapper = new ObjectMapper();
2952 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2953 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2954 assertEquals(Action.replaceInstance, action);
2958 public void handleReplaceInstance_retainAssignments_Test()
2959 throws JsonParseException, JsonMappingException, IOException {
2960 String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
2961 ObjectMapper mapper = new ObjectMapper();
2962 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2963 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2964 assertEquals(Action.replaceInstanceRetainAssignments, action);
2968 public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
2969 RequestError expectedResponse =
2970 mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
2971 uri = servInstanceuri + "v7"
2972 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
2973 ResponseEntity<String> response =
2974 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
2976 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2977 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2978 assertThat(expectedResponse, sameBeanAs(realResponse));