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());
1501 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d",
1502 response.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID).get(0));
1506 public void inPlaceSoftwareUpdate() throws IOException {
1507 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1508 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1509 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1511 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1512 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1513 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1514 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1515 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1517 // expected response
1518 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1519 RequestReferences requestReferences = new RequestReferences();
1520 requestReferences.setInstanceId("1882939");
1521 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1522 expectedResponse.setRequestReferences(requestReferences);
1523 uri = servInstanceuri + "v7"
1524 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1525 ResponseEntity<String> response =
1526 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1528 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1529 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1530 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1534 public void deleteVfModuleInstance() throws IOException {
1535 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1536 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1537 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1540 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1541 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1542 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1543 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1544 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1546 wireMockServer.stubFor(get(urlMatching(
1547 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1548 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1549 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1550 .withBody(getWiremockResponseForCatalogdb(
1551 "vnfComponentRecipeDeleteVfModule_Response.json"))
1552 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1554 // expected response
1555 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1556 RequestReferences requestReferences = new RequestReferences();
1557 requestReferences.setInstanceId("1882939");
1558 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1559 expectedResponse.setRequestReferences(requestReferences);
1560 uri = servInstanceuri + "v7"
1561 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1562 ResponseEntity<String> response =
1563 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1565 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1566 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1567 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1571 public void deleteVfModuleNoModelInvariantId() throws IOException {
1572 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1573 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1574 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1576 wireMockServer.stubFor(get(urlMatching(
1577 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1578 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1579 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1580 .withBody(getWiremockResponseForCatalogdb(
1581 "vnfComponentRecipeDeleteVfModule_Response.json"))
1582 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1584 // expected response
1585 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1586 RequestReferences requestReferences = new RequestReferences();
1587 requestReferences.setInstanceId("1882939");
1588 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1589 expectedResponse.setRequestReferences(requestReferences);
1590 uri = servInstanceuri + "v7"
1591 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1592 ResponseEntity<String> response =
1593 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1595 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1596 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1597 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1601 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1602 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1604 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1607 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1608 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1609 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1610 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1611 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1613 wireMockServer.stubFor(get(urlMatching(
1614 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1615 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1616 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1617 .withBody(getWiremockResponseForCatalogdb(
1618 "vnfComponentRecipeDeactivate_Response.json"))
1619 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1621 // expected response
1622 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1623 RequestReferences requestReferences = new RequestReferences();
1624 requestReferences.setInstanceId("1882939");
1625 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1626 expectedResponse.setRequestReferences(requestReferences);
1627 uri = servInstanceuri + "v7"
1628 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1629 ResponseEntity<String> response =
1630 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1632 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1633 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1634 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1638 public void createVolumeGroupInstance() throws IOException {
1639 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1640 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1641 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1643 wireMockServer.stubFor(get(urlMatching(
1644 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1645 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1646 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1647 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1649 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1650 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1651 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1652 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1654 wireMockServer.stubFor(get(urlMatching(
1655 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1656 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1657 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1658 .withBody(getWiremockResponseForCatalogdb(
1659 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1660 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1662 // expected response
1663 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1664 RequestReferences requestReferences = new RequestReferences();
1665 requestReferences.setInstanceId("1882939");
1666 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1667 expectedResponse.setRequestReferences(requestReferences);
1668 uri = servInstanceuri + "v7"
1669 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1670 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1672 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1673 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1674 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1675 assertTrue(response.getBody().contains("1882939"));
1679 public void updateVolumeGroupInstance() throws IOException {
1680 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1681 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1682 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1684 wireMockServer.stubFor(get(urlMatching(
1685 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1686 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1687 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1688 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1690 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1691 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1692 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1693 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1695 wireMockServer.stubFor(get(urlMatching(
1696 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1697 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1698 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1699 .withBody(getWiremockResponseForCatalogdb(
1700 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1701 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1703 // expected response
1704 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1705 RequestReferences requestReferences = new RequestReferences();
1706 requestReferences.setInstanceId("1882939");
1707 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1708 expectedResponse.setRequestReferences(requestReferences);
1709 uri = servInstanceuri + "v7"
1710 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1711 ResponseEntity<String> response =
1712 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1714 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1715 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1716 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1720 public void deleteVolumeGroupInstance() throws IOException {
1721 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1722 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1723 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1725 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1726 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1727 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1729 wireMockServer.stubFor(get(urlMatching(
1730 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1731 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1732 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1733 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1735 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1736 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1737 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1738 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1740 wireMockServer.stubFor(get(urlMatching(
1741 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1742 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1743 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1744 .withBody(getWiremockResponseForCatalogdb(
1745 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1746 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1748 // expected response
1749 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1750 RequestReferences requestReferences = new RequestReferences();
1751 requestReferences.setInstanceId("1882939");
1752 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1753 expectedResponse.setRequestReferences(requestReferences);
1754 uri = servInstanceuri + "v7"
1755 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1756 ResponseEntity<String> response =
1757 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1759 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1760 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1761 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1765 public void createNetworkInstance() throws IOException {
1766 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1767 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1768 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1770 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1771 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1772 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1773 .withStatus(HttpStatus.SC_OK)));
1775 wireMockServer.stubFor(
1776 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1777 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1778 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1779 .withStatus(HttpStatus.SC_OK)));
1781 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1782 + "modelName=GR-API-DEFAULT&action=createInstance"))
1783 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1784 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1785 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1787 // expected response
1788 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1789 RequestReferences requestReferences = new RequestReferences();
1790 requestReferences.setInstanceId("1882939");
1791 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1792 expectedResponse.setRequestReferences(requestReferences);
1793 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1794 ResponseEntity<String> response =
1795 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1797 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1798 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1799 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1803 public void updateNetworkInstance() throws IOException {
1804 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1805 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1806 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1808 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1809 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1810 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1811 .withStatus(HttpStatus.SC_OK)));
1813 wireMockServer.stubFor(
1814 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1815 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1816 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1817 .withStatus(HttpStatus.SC_OK)));
1819 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1820 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1821 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1822 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1823 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1824 // expected response
1825 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1826 RequestReferences requestReferences = new RequestReferences();
1827 requestReferences.setInstanceId("1882939");
1828 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1829 expectedResponse.setRequestReferences(requestReferences);
1830 uri = servInstanceuri + "v7"
1831 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1832 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1834 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1835 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1836 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1837 assertTrue(response.getBody().contains("1882939"));
1841 public void deleteNetworkInstance() throws IOException {
1842 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1843 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1844 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1846 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1847 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1848 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1849 .withStatus(HttpStatus.SC_OK)));
1851 wireMockServer.stubFor(
1852 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1853 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1854 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1855 .withStatus(HttpStatus.SC_OK)));
1857 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1858 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1859 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1860 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1861 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1863 // expected response
1864 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1865 RequestReferences requestReferences = new RequestReferences();
1866 requestReferences.setInstanceId("1882939");
1867 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1868 expectedResponse.setRequestReferences(requestReferences);
1869 uri = servInstanceuri + "v7"
1870 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1871 ResponseEntity<String> response =
1872 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1874 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1875 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1876 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1880 public void deleteNetworkInstanceNoReqParams() throws IOException {
1881 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1882 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1883 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1885 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1886 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1887 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1888 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1889 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1892 // expected response
1893 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1894 RequestReferences requestReferences = new RequestReferences();
1895 requestReferences.setInstanceId("1882939");
1896 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1897 expectedResponse.setRequestReferences(requestReferences);
1898 uri = servInstanceuri + "v6"
1899 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1900 ResponseEntity<String> response =
1901 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1903 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1904 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1905 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1909 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1911 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1912 expectedRecord.setRequestStatus("FAILED");
1913 expectedRecord.setStatusMessage("Error mapping request: ");
1914 expectedRecord.setProgress(100L);
1915 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1916 expectedRecord.setLastModifiedBy("APIH");
1917 expectedRecord.setRequestScope("network");
1918 expectedRecord.setRequestAction("deleteInstance");
1919 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1921 uri = servInstanceuri + "v6"
1922 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1923 ResponseEntity<String> response =
1924 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1928 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1932 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1933 uri = servInstanceuri + "v5"
1934 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1935 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1937 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1941 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1942 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1943 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1944 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1946 ServiceRecipe serviceRecipe = new ServiceRecipe();
1947 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1948 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1949 serviceRecipe.setAction(Action.createInstance.toString());
1950 serviceRecipe.setId(1);
1951 serviceRecipe.setRecipeTimeout(180);
1952 Service defaultService = new Service();
1953 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1955 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1956 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1957 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1959 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
1960 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1961 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
1963 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1964 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1965 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1967 uri = servInstanceuri + "v7" + "/serviceInstances";
1968 ResponseEntity<String> response =
1969 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1971 // expected response
1972 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1973 RequestReferences requestReferences = new RequestReferences();
1974 requestReferences.setInstanceId("1882939");
1975 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1976 expectedResponse.setRequestReferences(requestReferences);
1978 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1979 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1980 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1984 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1985 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1986 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1987 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1989 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1990 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1991 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1992 .withStatus(HttpStatus.SC_OK)));
1994 wireMockServer.stubFor(
1995 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1996 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1997 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1998 .withStatus(HttpStatus.SC_OK)));
2000 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2001 + "modelName=GR-API-DEFAULT&action=createInstance"))
2002 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2003 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2004 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2006 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2007 ResponseEntity<String> response =
2008 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
2010 // expected response
2011 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2012 RequestReferences requestReferences = new RequestReferences();
2013 requestReferences.setInstanceId("1882939");
2014 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2015 expectedResponse.setRequestReferences(requestReferences);
2017 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2018 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2019 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2023 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
2024 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2025 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2026 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2028 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2029 ResponseEntity<String> response =
2030 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
2032 // expected response
2033 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2034 RequestReferences requestReferences = new RequestReferences();
2035 requestReferences.setInstanceId("1882939");
2036 expectedResponse.setRequestReferences(requestReferences);
2038 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2042 public void createNetworkInstanceTestApiGrApi() throws IOException {
2043 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2044 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2045 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2047 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2048 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2049 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2050 .withStatus(HttpStatus.SC_OK)));
2052 wireMockServer.stubFor(
2053 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2054 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2055 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2056 .withStatus(HttpStatus.SC_OK)));
2058 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2059 + "modelName=GR-API-DEFAULT&action=createInstance"))
2060 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2061 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2062 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2064 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2065 ResponseEntity<String> response =
2066 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2068 // expected response
2069 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2070 RequestReferences requestReferences = new RequestReferences();
2071 requestReferences.setInstanceId("1882939");
2072 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2073 expectedResponse.setRequestReferences(requestReferences);
2075 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2076 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2077 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2081 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2082 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2083 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2084 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2086 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2087 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2088 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2089 .withStatus(HttpStatus.SC_OK)));
2091 wireMockServer.stubFor(
2092 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2093 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2094 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2095 .withStatus(HttpStatus.SC_OK)));
2097 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2098 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2099 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2100 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2101 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2103 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2104 ResponseEntity<String> response =
2105 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2107 // expected response
2108 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2109 RequestReferences requestReferences = new RequestReferences();
2110 requestReferences.setInstanceId("1882939");
2111 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2112 expectedResponse.setRequestReferences(requestReferences);
2114 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2115 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2116 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2120 public void activateServiceInstanceRequestStatus() throws IOException {
2121 ServiceRecipe serviceRecipe = new ServiceRecipe();
2122 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2123 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2124 serviceRecipe.setAction(Action.createInstance.toString());
2125 serviceRecipe.setId(1);
2126 serviceRecipe.setRecipeTimeout(180);
2127 Service defaultService = new Service();
2128 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2130 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2131 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2132 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2134 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2135 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2136 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2138 wireMockServer.stubFor(get(urlMatching(".*/service-design-and-creation/services/service/.*"))
2139 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2140 .withBodyFile("/aai/ServiceFromAAI.json").withStatus(HttpStatus.SC_OK)));
2142 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2143 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2144 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2147 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2148 RequestReferences requestReferences = new RequestReferences();
2149 requestReferences.setInstanceId("1882939");
2150 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2151 expectedResponse.setRequestReferences(requestReferences);
2152 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2153 ResponseEntity<String> response =
2154 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2156 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2157 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2158 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2162 public void invalidRequestId() throws IOException {
2163 String illegalRequestId = "1234";
2164 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2165 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2166 uri = servInstanceuri + "v5/serviceInstances";
2167 ResponseEntity<String> response =
2168 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2170 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2171 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2175 public void invalidBPELResponse() throws IOException {
2177 ServiceRecipe serviceRecipe = new ServiceRecipe();
2178 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2179 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2180 serviceRecipe.setAction(Action.createInstance.toString());
2181 serviceRecipe.setId(1);
2182 serviceRecipe.setRecipeTimeout(180);
2183 Service defaultService = new Service();
2184 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2186 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2187 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2188 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2190 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2191 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2192 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2194 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2195 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2196 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2198 uri = servInstanceuri + "v5/serviceInstances";
2199 ResponseEntity<String> response =
2200 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2202 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2203 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2204 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2205 realResponse.getServiceException().getText());
2209 public void unauthorizedBPELResponse() throws IOException {
2211 ServiceRecipe serviceRecipe = new ServiceRecipe();
2212 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2213 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2214 serviceRecipe.setAction(Action.createInstance.toString());
2215 serviceRecipe.setId(1);
2216 serviceRecipe.setRecipeTimeout(180);
2217 Service defaultService = new Service();
2218 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2220 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2221 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2222 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2224 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2225 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2226 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2228 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2229 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2230 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2232 uri = servInstanceuri + "v5/serviceInstances";
2233 ResponseEntity<String> response =
2234 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2236 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2237 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2238 assertEquals("Request Failed due to BPEL error with HTTP Status = 401 UNAUTHORIZED",
2239 realResponse.getServiceException().getText());
2243 public void invalidBPELResponse2() throws IOException {
2245 ServiceRecipe serviceRecipe = new ServiceRecipe();
2246 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2247 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2248 serviceRecipe.setAction(Action.createInstance.toString());
2249 serviceRecipe.setId(1);
2250 serviceRecipe.setRecipeTimeout(180);
2251 Service defaultService = new Service();
2252 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2254 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2255 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2256 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2258 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2259 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2260 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2262 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2263 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2264 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2265 uri = servInstanceuri + "v5/serviceInstances";
2266 ResponseEntity<String> response =
2267 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2269 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2270 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2271 assertTrue(realResponse.getServiceException().getText()
2272 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2276 public void createMacroServiceInstance() throws IOException {
2277 ServiceRecipe serviceRecipe = new ServiceRecipe();
2278 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2279 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2280 serviceRecipe.setAction(Action.createInstance.toString());
2281 serviceRecipe.setId(1);
2282 serviceRecipe.setRecipeTimeout(180);
2283 Service defaultService = new Service();
2284 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2286 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2287 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2288 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2290 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2291 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2292 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2294 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2295 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2296 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2298 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2299 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2300 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2303 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2304 RequestReferences requestReferences = new RequestReferences();
2305 requestReferences.setInstanceId("1882939");
2306 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2307 expectedResponse.setRequestReferences(requestReferences);
2308 uri = servInstanceuri + "v5";
2309 ResponseEntity<String> response =
2310 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2313 assertEquals(404, response.getStatusCode().value());
2317 public void testUserParams() throws IOException {
2318 ObjectMapper mapper = new ObjectMapper();
2319 ServiceInstancesRequest request =
2320 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2321 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2322 String userParamsTxt = inputStream("/userParams.txt");
2324 List<Map<String, Object>> userParams = requestHandlerUtils.configureUserParams(requestParameters);
2325 System.out.println(userParams);
2326 assertTrue(userParams.size() > 0);
2327 assertTrue(userParams.get(0).containsKey("name"));
2328 assertTrue(userParams.get(0).containsKey("value"));
2329 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2333 public void testConfigureCloudConfig() throws IOException {
2334 ObjectMapper mapper = new ObjectMapper();
2335 ServiceInstancesRequest request =
2336 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2337 CloudConfiguration cloudConfig =
2338 requestHandlerUtils.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2340 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2341 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2345 public void testMapToLegacyRequest() throws IOException {
2346 ObjectMapper mapper = new ObjectMapper();
2347 ServiceInstancesRequest request =
2348 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2349 ServiceInstancesRequest expected =
2350 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2351 requestHandlerUtils.mapToLegacyRequest(request.getRequestDetails());
2352 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2353 assertThat(request, sameBeanAs(expected));
2357 public void scaleOutVfModule() throws IOException {
2358 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2359 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2360 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2362 wireMockServer.stubFor(get(urlMatching(
2363 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2365 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2366 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2368 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2369 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2370 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2371 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2373 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2374 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2375 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2376 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2379 wireMockServer.stubFor(get(urlMatching(
2380 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2381 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2382 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2383 .withBody(getWiremockResponseForCatalogdb(
2384 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2385 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2387 wireMockServer.stubFor(get(urlMatching(
2388 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2389 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2390 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2391 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2393 // expected response
2394 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2395 RequestReferences requestReferences = new RequestReferences();
2396 requestReferences.setInstanceId("1882939");
2397 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2398 expectedResponse.setRequestReferences(requestReferences);
2399 uri = servInstanceuri + "v7"
2400 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2401 ResponseEntity<String> response =
2402 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2404 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2405 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2406 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2407 assertTrue(response.getBody().contains("1882939"));
2411 public void createServiceInstanceBadResponse() throws IOException {
2412 ServiceRecipe serviceRecipe = new ServiceRecipe();
2413 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2414 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2415 serviceRecipe.setAction(Action.createInstance.toString());
2416 serviceRecipe.setId(1);
2417 serviceRecipe.setRecipeTimeout(180);
2418 Service defaultService = new Service();
2419 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2421 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2422 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2423 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2425 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2426 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2427 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2429 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2430 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2431 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2433 uri = servInstanceuri + "v5/serviceInstances";
2434 ResponseEntity<String> response =
2435 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2437 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2438 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2439 assertEquals("Exception caught mapping Camunda JSON response to object",
2440 realResponse.getServiceException().getText());
2444 public void createServiceInstanceDuplicateError() throws IOException {
2445 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2446 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2447 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2449 uri = servInstanceuri + "v5/serviceInstances";
2450 ResponseEntity<String> response =
2451 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2453 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2454 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2456 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
2457 realResponse.getServiceException().getText());
2461 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2462 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2463 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2464 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2465 .withStatus(HttpStatus.SC_ACCEPTED)));
2466 wireMockServer.stubFor(get(
2467 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2468 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2469 .withBodyFile("Camunda/HistoryCheckResponse.json")
2470 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2472 uri = servInstanceuri + "v5/serviceInstances";
2473 ResponseEntity<String> response =
2474 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2476 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2477 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2479 "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.",
2480 realResponse.getServiceException().getText());
2484 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2485 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2487 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2488 .withStatus(HttpStatus.SC_ACCEPTED)));
2489 wireMockServer.stubFor(get(
2490 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2491 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2492 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2494 uri = servInstanceuri + "v5/serviceInstances";
2495 ResponseEntity<String> response =
2496 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2498 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2499 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2501 "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
2502 realResponse.getServiceException().getText());
2506 public void createServiceInstanceDuplicate() throws IOException {
2507 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2508 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2509 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2511 uri = servInstanceuri + "v5/serviceInstances";
2512 ResponseEntity<String> response =
2513 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2515 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2516 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2518 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
2519 realResponse.getServiceException().getText());
2523 public void createServiceInstanceSaveError() throws IOException {
2524 ServiceRecipe serviceRecipe = new ServiceRecipe();
2525 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2526 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2527 serviceRecipe.setAction(Action.createInstance.toString());
2528 serviceRecipe.setId(1);
2529 serviceRecipe.setRecipeTimeout(180);
2530 Service defaultService = new Service();
2531 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2532 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2533 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2534 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2535 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2536 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2537 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2539 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2540 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2541 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2543 uri = servInstanceuri + "v5/serviceInstances";
2544 ResponseEntity<String> response =
2545 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2547 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2548 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2550 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
2551 realResponse.getServiceException().getText());
2555 public void createPortConfigurationSaveError() throws IOException {
2556 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2557 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2558 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2559 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2560 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2561 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2563 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2564 ResponseEntity<String> response =
2565 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2567 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2568 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2570 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
2571 realResponse.getServiceException().getText());
2575 public void createPortConfigDbUpdateError() throws IOException {
2576 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2577 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2578 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2580 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2581 ResponseEntity<String> response =
2582 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2584 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2585 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2587 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
2588 realResponse.getServiceException().getText());
2592 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2593 TestAppender.events.clear();
2594 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2596 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2598 wireMockServer.stubFor(get(urlMatching(
2599 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2601 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2602 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2604 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2605 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2606 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2607 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2609 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2610 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2611 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2612 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2613 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2614 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2616 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2617 RequestReferences requestReferences = new RequestReferences();
2618 requestReferences.setInstanceId("1882939");
2619 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2620 expectedResponse.setRequestReferences(requestReferences);
2621 uri = servInstanceuri
2622 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2623 ResponseEntity<String> response =
2624 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2626 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2627 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2628 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2629 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2633 public void createInstanceGroup() throws IOException {
2634 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2635 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2636 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2639 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2640 RequestReferences requestReferences = new RequestReferences();
2641 requestReferences.setInstanceId("1882939");
2642 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2643 expectedResponse.setRequestReferences(requestReferences);
2644 uri = servInstanceuri + "/v7/instanceGroups";
2645 ResponseEntity<String> response =
2646 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2649 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2650 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2651 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2655 public void deleteInstanceGroup() throws IOException {
2656 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2657 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2658 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2661 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2662 RequestReferences requestReferences = new RequestReferences();
2663 requestReferences.setInstanceId("1882939");
2664 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2665 expectedResponse.setRequestReferences(requestReferences);
2666 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2667 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2670 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2671 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2672 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2676 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2677 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2678 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2680 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2681 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2682 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2686 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2687 HttpHeaders noPartnerHeaders = new HttpHeaders();
2688 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2689 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2690 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2691 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2693 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2694 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2695 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2699 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2700 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2701 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2702 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2704 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2705 RequestReferences requestReferences = new RequestReferences();
2706 requestReferences.setInstanceId("1882939");
2707 expectedResponse.setRequestReferences(requestReferences);
2708 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2709 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2712 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2713 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2714 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2718 public void addMembers() throws IOException {
2719 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2720 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2721 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2723 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2724 RequestReferences requestReferences = new RequestReferences();
2725 requestReferences.setInstanceId("1882939");
2726 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2727 expectedResponse.setRequestReferences(requestReferences);
2728 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2729 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2732 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2733 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2734 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2738 public void removeMembers() throws IOException {
2739 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2740 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2741 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2743 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2744 RequestReferences requestReferences = new RequestReferences();
2745 requestReferences.setInstanceId("1882939");
2746 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2747 expectedResponse.setRequestReferences(requestReferences);
2748 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2749 ResponseEntity<String> response =
2750 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2753 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2754 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2755 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2759 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2760 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2761 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2762 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2764 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2765 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2766 .withStatus(HttpStatus.SC_NOT_FOUND)));
2768 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2769 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2770 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2771 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2772 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2774 // expected response
2775 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2776 RequestReferences requestReferences = new RequestReferences();
2777 requestReferences.setInstanceId("1882939");
2778 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2779 expectedResponse.setRequestReferences(requestReferences);
2780 uri = servInstanceuri + "v7"
2781 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2782 ResponseEntity<String> response =
2783 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2785 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2786 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2787 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2791 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2792 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2793 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2794 .withStatus(HttpStatus.SC_NOT_FOUND)));
2796 uri = servInstanceuri + "v7"
2797 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2798 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2800 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2801 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2802 assertEquals(realResponse.getServiceException().getText(),
2803 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2807 public void setServiceTypeTestALaCarte() throws JsonProcessingException {
2808 String requestScope = ModelType.service.toString();
2809 Boolean aLaCarteFlag = true;
2810 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2811 RequestDetails requestDetails = new RequestDetails();
2812 RequestInfo requestInfo = new RequestInfo();
2813 requestInfo.setSource("VID");
2814 requestDetails.setRequestInfo(requestInfo);
2815 sir.setRequestDetails(requestDetails);
2816 Service defaultService = new Service();
2817 defaultService.setServiceType("testServiceTypeALaCarte");
2819 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2820 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2821 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2823 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2824 assertEquals(serviceType, "testServiceTypeALaCarte");
2828 public void setServiceTypeTest() throws JsonProcessingException {
2829 String requestScope = ModelType.service.toString();
2830 Boolean aLaCarteFlag = false;
2831 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2832 RequestDetails requestDetails = new RequestDetails();
2833 RequestInfo requestInfo = new RequestInfo();
2834 ModelInfo modelInfo = new ModelInfo();
2835 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2836 requestInfo.setSource("VID");
2837 requestDetails.setModelInfo(modelInfo);
2838 requestDetails.setRequestInfo(requestInfo);
2839 sir.setRequestDetails(requestDetails);
2840 Service defaultService = new Service();
2841 defaultService.setServiceType("testServiceType");
2843 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2844 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2845 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2847 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2848 assertEquals(serviceType, "testServiceType");
2852 public void setServiceTypeTestDefault() throws JsonProcessingException {
2853 String requestScope = ModelType.service.toString();
2854 Boolean aLaCarteFlag = false;
2855 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2856 RequestDetails requestDetails = new RequestDetails();
2857 RequestInfo requestInfo = new RequestInfo();
2858 ModelInfo modelInfo = new ModelInfo();
2859 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2860 requestInfo.setSource("VID");
2861 requestDetails.setModelInfo(modelInfo);
2862 requestDetails.setRequestInfo(requestInfo);
2863 sir.setRequestDetails(requestDetails);
2864 Service defaultService = new Service();
2865 defaultService.setServiceType("testServiceType");
2867 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2868 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2869 .withStatus(HttpStatus.SC_NOT_FOUND)));
2870 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2871 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2872 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2874 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2875 assertEquals(serviceType, "testServiceType");
2879 public void setServiceTypeTestNetwork() throws JsonProcessingException {
2880 String requestScope = ModelType.network.toString();
2881 Boolean aLaCarteFlag = null;
2882 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2883 RequestDetails requestDetails = new RequestDetails();
2884 RequestInfo requestInfo = new RequestInfo();
2885 ModelInfo modelInfo = new ModelInfo();
2886 modelInfo.setModelName("networkModelName");
2887 requestInfo.setSource("VID");
2888 requestDetails.setModelInfo(modelInfo);
2889 requestDetails.setRequestInfo(requestInfo);
2890 sir.setRequestDetails(requestDetails);
2892 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2893 assertEquals(serviceType, "networkModelName");
2897 public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
2898 String requestScope = "instanceGroup";
2899 ServiceInstancesRequest sir =
2900 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
2901 assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
2902 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2906 public void setServiceInstanceIdTest() {
2907 String requestScope = "vnf";
2908 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2909 sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2910 assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
2911 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2915 public void setServiceInstanceIdReturnNullTest() {
2916 String requestScope = "vnf";
2917 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2918 assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2922 public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
2923 wireMockServer.stubFor(get(
2924 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2925 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2926 .withBodyFile("Camunda/HistoryCheckResponse.json")
2927 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2929 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2930 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2931 boolean inProgress = false;
2932 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2933 assertTrue(inProgress);
2937 public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
2938 wireMockServer.stubFor(get(
2939 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1"))
2940 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2941 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
2943 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2944 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2945 boolean inProgress = false;
2946 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2947 assertFalse(inProgress);
2951 public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
2952 String replaceVfModule = inputStream("/ReplaceVfModule.json");
2953 ObjectMapper mapper = new ObjectMapper();
2954 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2955 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2956 assertEquals(Action.replaceInstance, action);
2960 public void handleReplaceInstance_retainAssignments_Test()
2961 throws JsonParseException, JsonMappingException, IOException {
2962 String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
2963 ObjectMapper mapper = new ObjectMapper();
2964 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2965 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2966 assertEquals(Action.replaceInstanceRetainAssignments, action);
2970 public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
2971 RequestError expectedResponse =
2972 mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
2973 uri = servInstanceuri + "v7"
2974 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
2975 ResponseEntity<String> response =
2976 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
2978 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2979 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2980 assertThat(expectedResponse, sameBeanAs(realResponse));