2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.apihandlerinfra;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
29 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertFalse;
32 import static org.junit.Assert.assertNotNull;
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.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
37 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
38 import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
39 import static org.onap.so.logger.MdcConstants.CLIENT_ID;
40 import static org.onap.so.logger.MdcConstants.ENDTIME;
41 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
42 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
43 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
44 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
45 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
46 import static org.onap.so.logger.MdcConstants.STATUSCODE;
48 import java.io.IOException;
49 import java.net.MalformedURLException;
51 import java.nio.file.Files;
52 import java.nio.file.Paths;
53 import java.util.List;
55 import javax.ws.rs.core.MediaType;
56 import javax.ws.rs.core.Response;
57 import org.apache.http.HttpStatus;
58 import org.junit.Before;
59 import org.junit.Test;
60 import org.mockito.Mockito;
61 import org.onap.logging.ref.slf4j.ONAPLogConstants;
62 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
63 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
64 import org.onap.so.db.catalog.beans.Service;
65 import org.onap.so.db.catalog.beans.ServiceRecipe;
66 import org.onap.so.db.request.beans.InfraActiveRequests;
67 import org.onap.so.logger.HttpHeadersConstants;
68 import org.onap.so.serviceinstancebeans.CloudConfiguration;
69 import org.onap.so.serviceinstancebeans.ModelInfo;
70 import org.onap.so.serviceinstancebeans.ModelType;
71 import org.onap.so.serviceinstancebeans.RequestDetails;
72 import org.onap.so.serviceinstancebeans.RequestError;
73 import org.onap.so.serviceinstancebeans.RequestInfo;
74 import org.onap.so.serviceinstancebeans.RequestParameters;
75 import org.onap.so.serviceinstancebeans.RequestReferences;
76 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
77 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
78 import org.springframework.beans.factory.annotation.Autowired;
79 import org.springframework.beans.factory.annotation.Value;
80 import org.springframework.http.HttpEntity;
81 import org.springframework.http.HttpHeaders;
82 import org.springframework.http.HttpMethod;
83 import org.springframework.http.ResponseEntity;
84 import org.springframework.util.ResourceUtils;
85 import org.springframework.web.util.UriComponentsBuilder;
86 import com.fasterxml.jackson.core.JsonParseException;
87 import com.fasterxml.jackson.core.JsonProcessingException;
88 import com.fasterxml.jackson.databind.DeserializationFeature;
89 import com.fasterxml.jackson.databind.JsonMappingException;
90 import com.fasterxml.jackson.databind.ObjectMapper;
91 import com.github.tomakehurst.wiremock.http.Fault;
92 import ch.qos.logback.classic.spi.ILoggingEvent;
94 public class ServiceInstancesTest extends BaseTest {
96 private final ObjectMapper mapper = new ObjectMapper();
97 private ObjectMapper errorMapper = new ObjectMapper();
100 private ServiceInstances servInstances;
103 private RequestHandlerUtils requestHandlerUtils;
105 @Value("${wiremock.server.port}")
106 private String wiremockPort;
108 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
109 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
111 private URL selfLink;
112 private URL initialUrl;
113 private int initialPort;
114 private HttpHeaders headers;
117 public void beforeClass() {
118 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
119 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
120 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
122 headers = new HttpHeaders();
123 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
124 headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
125 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
126 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
127 headers.set(CLIENT_ID, "VID");
128 headers.set(REQUESTOR_ID, "xxxxxx");
129 try { // generate one-time port number to avoid RANDOM port number later.
130 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
131 initialPort = initialUrl.getPort();
132 } catch (MalformedURLException e) {
135 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*")).willReturn(aResponse()
136 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
137 Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
140 public String inputStream(String JsonInput) throws IOException {
141 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
142 return new String(Files.readAllBytes(Paths.get(JsonInput)));
145 private URL createExpectedSelfLink(String version, String requestId) {
146 System.out.println("createdUrl: " + initialUrl.toString());
148 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
149 } catch (MalformedURLException e) {
155 private String getWiremockResponseForCatalogdb(String file) {
157 File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
158 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
159 "localhost:" + wiremockPort);
160 } catch (IOException e) {
167 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
168 HttpHeaders headers) {
170 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
171 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
173 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
174 headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
177 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
179 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
181 return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
184 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
185 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
189 public void createServiceInstanceVIDDefault() throws IOException {
190 TestAppender.events.clear();
192 ServiceRecipe serviceRecipe = new ServiceRecipe();
193 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
194 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
195 serviceRecipe.setAction(Action.createInstance.toString());
196 serviceRecipe.setId(1);
197 serviceRecipe.setRecipeTimeout(180);
198 Service defaultService = new Service();
199 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
202 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
204 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
206 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
207 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
208 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
210 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
211 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
212 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
215 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
216 RequestReferences requestReferences = new RequestReferences();
217 requestReferences.setInstanceId("1882939");
218 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
219 expectedResponse.setRequestReferences(requestReferences);
220 uri = servInstanceuri + "v5/serviceInstances";
221 ResponseEntity<String> response =
222 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
225 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
226 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
227 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
231 for (ILoggingEvent logEvent : TestAppender.events)
232 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
233 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
234 Map<String, String> mdc = logEvent.getMDCPropertyMap();
235 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
236 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
237 assertNotNull(mdc.get(INVOCATION_ID));
238 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
239 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
240 assertEquals("INPROGRESS", mdc.get(STATUSCODE));
241 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
242 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
243 Map<String, String> mdc = logEvent.getMDCPropertyMap();
244 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
245 assertNotNull(mdc.get(ENDTIME));
246 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
247 assertNotNull(mdc.get(INVOCATION_ID));
248 assertEquals("202", mdc.get(RESPONSECODE));
249 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
250 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
251 assertEquals("COMPLETE", mdc.get(STATUSCODE));
252 assertNotNull(mdc.get(RESPONSEDESC));
253 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
254 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
255 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
260 public void createServiceInstanceServiceInstancesUri() throws IOException {
261 ServiceRecipe serviceRecipe = new ServiceRecipe();
262 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
263 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
264 serviceRecipe.setAction(Action.createInstance.toString());
265 serviceRecipe.setId(1);
266 serviceRecipe.setRecipeTimeout(180);
267 Service defaultService = new Service();
268 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
270 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
272 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
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 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
284 RequestReferences requestReferences = new RequestReferences();
285 requestReferences.setInstanceId("1882939");
286 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
287 expectedResponse.setRequestReferences(requestReferences);
288 uri = servInstanceuri + "v5";
289 ResponseEntity<String> response =
290 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
293 assertEquals(404, response.getStatusCode().value());
294 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
298 public void createServiceInstanceBpelStatusError() throws IOException {
299 ServiceRecipe serviceRecipe = new ServiceRecipe();
300 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
301 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
302 serviceRecipe.setAction(Action.createInstance.toString());
303 serviceRecipe.setId(1);
304 serviceRecipe.setRecipeTimeout(180);
305 Service defaultService = new Service();
306 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
309 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
310 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
311 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
314 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
315 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
316 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
318 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
319 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
320 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
322 uri = servInstanceuri + "v5/serviceInstances";
323 ResponseEntity<String> response =
324 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
326 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
330 public void createServiceInstanceBadGateway() throws IOException {
331 ServiceRecipe serviceRecipe = new ServiceRecipe();
332 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
333 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
334 serviceRecipe.setAction(Action.createInstance.toString());
335 serviceRecipe.setId(1);
336 serviceRecipe.setRecipeTimeout(180);
337 Service defaultService = new Service();
338 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
340 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
341 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
343 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
344 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
345 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
347 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
348 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
349 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
351 uri = servInstanceuri + "v5/serviceInstances";
352 ResponseEntity<String> response =
353 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
355 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
359 public void createServiceInstanceEmptyResponse() throws IOException {
360 ServiceRecipe serviceRecipe = new ServiceRecipe();
361 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
362 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
363 serviceRecipe.setAction(Action.createInstance.toString());
364 serviceRecipe.setId(1);
365 serviceRecipe.setRecipeTimeout(180);
366 Service defaultService = new Service();
367 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
369 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
370 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
372 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
373 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
374 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
376 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
377 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
378 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
380 uri = servInstanceuri + "v5/serviceInstances";
381 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
383 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
387 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
388 TestAppender.events.clear();
389 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
390 HttpHeaders requestIDheaders = new HttpHeaders();
391 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
392 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
393 HttpMethod.POST, requestIDheaders);
395 Service defaultService = new Service();
396 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
398 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
400 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
403 wireMockServer.stubFor(get(urlMatching(
404 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
405 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
406 .withStatus(HttpStatus.SC_NOT_FOUND)));
408 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
412 public void activateServiceInstanceNoRecipe() throws IOException {
413 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
414 Service defaultService = new Service();
415 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
416 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
417 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
418 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
420 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
421 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
423 ResponseEntity<String> response =
424 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
426 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
430 public void activateServiceInstance() throws IOException {
431 ServiceRecipe serviceRecipe = new ServiceRecipe();
432 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
433 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
434 serviceRecipe.setAction(Action.createInstance.toString());
435 serviceRecipe.setId(1);
436 serviceRecipe.setRecipeTimeout(180);
437 Service defaultService = new Service();
438 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
440 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
441 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
442 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
444 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
445 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
446 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
448 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
449 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
450 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
452 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
453 RequestReferences requestReferences = new RequestReferences();
454 requestReferences.setInstanceId("1882939");
455 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
456 expectedResponse.setRequestReferences(requestReferences);
457 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
458 ResponseEntity<String> response =
459 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
461 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
462 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
463 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
467 public void deactivateServiceInstance() throws IOException {
469 ServiceRecipe serviceRecipe = new ServiceRecipe();
470 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
471 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
472 serviceRecipe.setAction(Action.createInstance.toString());
473 serviceRecipe.setId(1);
474 serviceRecipe.setRecipeTimeout(180);
475 Service defaultService = new Service();
476 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
478 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
479 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
480 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
482 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
483 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
484 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
486 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
487 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
488 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
490 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
491 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
492 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
495 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
496 RequestReferences requestReferences = new RequestReferences();
497 requestReferences.setInstanceId("1882939");
498 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
499 expectedResponse.setRequestReferences(requestReferences);
500 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
501 ResponseEntity<String> response =
502 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
504 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
505 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
506 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
510 public void deleteServiceInstance() throws IOException {
511 ServiceRecipe serviceRecipe = new ServiceRecipe();
512 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
513 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
514 serviceRecipe.setAction(Action.createInstance.toString());
515 serviceRecipe.setId(1);
516 serviceRecipe.setRecipeTimeout(180);
517 Service defaultService = new Service();
518 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
520 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
522 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
524 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
526 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
528 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
530 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
532 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
533 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
534 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
536 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
537 RequestReferences requestReferences = new RequestReferences();
538 requestReferences.setInstanceId("1882939");
539 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
540 expectedResponse.setRequestReferences(requestReferences);
541 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
542 ResponseEntity<String> response =
543 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
545 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
546 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
547 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
551 public void assignServiceInstance() throws IOException {
552 ServiceRecipe serviceRecipe = new ServiceRecipe();
553 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
554 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
555 serviceRecipe.setAction(Action.createInstance.toString());
556 serviceRecipe.setId(1);
557 serviceRecipe.setRecipeTimeout(180);
558 Service defaultService = new Service();
559 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
561 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
562 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
563 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
565 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
566 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
567 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
569 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
570 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
571 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
573 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
574 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
575 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
577 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
578 RequestReferences requestReferences = new RequestReferences();
579 requestReferences.setInstanceId("1882939");
580 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
581 expectedResponse.setRequestReferences(requestReferences);
582 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
583 ResponseEntity<String> response =
584 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
586 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
587 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
588 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
592 public void unassignServiceInstance() throws IOException {
593 ServiceRecipe serviceRecipe = new ServiceRecipe();
594 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
595 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
596 serviceRecipe.setAction(Action.createInstance.toString());
597 serviceRecipe.setId(1);
598 serviceRecipe.setRecipeTimeout(180);
599 Service defaultService = new Service();
600 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
602 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
604 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
606 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
607 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
608 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
610 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
611 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
612 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
614 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
615 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
616 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
618 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
619 RequestReferences requestReferences = new RequestReferences();
620 requestReferences.setInstanceId("1882939");
621 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
622 expectedResponse.setRequestReferences(requestReferences);
623 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
624 ResponseEntity<String> response =
625 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
627 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
628 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
629 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
633 public void createPortConfiguration() throws IOException {
634 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
635 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
636 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
638 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
639 RequestReferences requestReferences = new RequestReferences();
640 requestReferences.setInstanceId("1882939");
641 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
642 expectedResponse.setRequestReferences(requestReferences);
643 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
644 ResponseEntity<String> response =
645 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
647 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
648 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
649 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
650 assertTrue(response.getBody().contains("1882939"));
654 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
655 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
656 ResponseEntity<String> response =
657 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
659 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
663 public void deletePortConfiguration() throws IOException {
664 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
665 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
666 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
669 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
670 RequestReferences requestReferences = new RequestReferences();
671 requestReferences.setInstanceId("1882939");
672 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
673 expectedResponse.setRequestReferences(requestReferences);
674 uri = servInstanceuri + "v7"
675 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
676 ResponseEntity<String> response =
677 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
679 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
680 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
681 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
685 public void enablePort() throws IOException {
686 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
687 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
688 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
690 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
691 RequestReferences requestReferences = new RequestReferences();
692 requestReferences.setInstanceId("1882939");
693 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
694 expectedResponse.setRequestReferences(requestReferences);
695 uri = servInstanceuri + "v7"
696 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
697 ResponseEntity<String> response =
698 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
700 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
701 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
702 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
706 public void disablePort() throws IOException {
707 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
708 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
709 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
711 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
712 RequestReferences requestReferences = new RequestReferences();
713 requestReferences.setInstanceId("1882939");
714 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
715 expectedResponse.setRequestReferences(requestReferences);
716 uri = servInstanceuri + "v7"
717 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
718 ResponseEntity<String> response =
719 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
721 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
722 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
723 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
727 public void activatePort() throws IOException {
728 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
729 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
730 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
732 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
733 RequestReferences requestReferences = new RequestReferences();
734 requestReferences.setInstanceId("1882939");
735 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
736 expectedResponse.setRequestReferences(requestReferences);
737 uri = servInstanceuri + "v7"
738 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
739 ResponseEntity<String> response =
740 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
742 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
743 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
744 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
748 public void deactivatePort() throws IOException {
749 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
750 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
751 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
753 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
754 RequestReferences requestReferences = new RequestReferences();
755 requestReferences.setInstanceId("1882939");
756 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
757 expectedResponse.setRequestReferences(requestReferences);
758 uri = servInstanceuri + "v7"
759 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
760 ResponseEntity<String> response =
761 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
763 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
764 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
765 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
769 public void addRelationships() throws IOException {
770 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
771 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
772 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
774 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
775 RequestReferences requestReferences = new RequestReferences();
776 requestReferences.setInstanceId("1882939");
777 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
778 expectedResponse.setRequestReferences(requestReferences);
779 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
780 ResponseEntity<String> response =
781 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
783 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
784 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
785 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
789 public void removeRelationships() throws IOException {
790 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
791 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
792 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
794 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
795 RequestReferences requestReferences = new RequestReferences();
796 requestReferences.setInstanceId("1882939");
797 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
798 expectedResponse.setRequestReferences(requestReferences);
799 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
800 ResponseEntity<String> response =
801 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
803 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
804 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
805 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
809 public void createVnfInstanceNoALaCarte() throws IOException {
810 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
812 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
815 wireMockServer.stubFor(get(urlMatching(
816 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
817 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
818 .withBody(getWiremockResponseForCatalogdb(
819 "vnfResourceCustomization_ReplaceVnf_Response.json"))
820 .withStatus(org.apache.http.HttpStatus.SC_OK)));
822 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
823 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
824 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
825 .withStatus(org.apache.http.HttpStatus.SC_OK)));
827 wireMockServer.stubFor(get(urlMatching(
828 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
829 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
830 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
831 .withStatus(org.apache.http.HttpStatus.SC_OK)));
834 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
835 RequestReferences requestReferences = new RequestReferences();
836 requestReferences.setInstanceId("1882939");
837 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
838 expectedResponse.setRequestReferences(requestReferences);
839 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
840 ResponseEntity<String> response =
841 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
843 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
844 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
845 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
849 public void createVnfInstance() throws IOException {
850 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
851 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
852 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
854 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
855 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
856 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
857 .withStatus(org.apache.http.HttpStatus.SC_OK)));
858 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
859 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
860 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
861 .withStatus(org.apache.http.HttpStatus.SC_OK)));
864 wireMockServer.stubFor(
865 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
866 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
867 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
868 .withStatus(org.apache.http.HttpStatus.SC_OK)));
870 wireMockServer.stubFor(get(urlMatching(
871 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
872 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
873 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
874 .withStatus(org.apache.http.HttpStatus.SC_OK)));
877 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
878 RequestReferences requestReferences = new RequestReferences();
879 requestReferences.setInstanceId("1882939");
880 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
881 expectedResponse.setRequestReferences(requestReferences);
882 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
883 ResponseEntity<String> response =
884 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
886 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
887 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
888 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
889 assertTrue(response.getBody().contains("1882939"));
893 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
894 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
895 ResponseEntity<String> response =
896 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
898 assertEquals(404, response.getStatusCode().value());
902 public void createVnfInstanceInvalidVnfResource() throws IOException {
903 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
904 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
906 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
907 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
908 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
912 public void replaceVnfInstance() throws IOException {
913 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
914 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
915 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
917 wireMockServer.stubFor(get(urlMatching(
918 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
919 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
920 .withBody(getWiremockResponseForCatalogdb(
921 "vnfResourceCustomization_ReplaceVnf_Response.json"))
922 .withStatus(org.apache.http.HttpStatus.SC_OK)));
924 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
925 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
926 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
927 .withStatus(org.apache.http.HttpStatus.SC_OK)));
929 wireMockServer.stubFor(get(urlMatching(
930 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
931 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
932 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
933 .withStatus(org.apache.http.HttpStatus.SC_OK)));
935 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
936 RequestReferences requestReferences = new RequestReferences();
937 requestReferences.setInstanceId("1882939");
938 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
939 expectedResponse.setRequestReferences(requestReferences);
940 uri = servInstanceuri + "v7"
941 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
942 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
944 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
945 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
946 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
950 public void replaceVnfRecreateInstance() throws IOException {
951 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
952 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
953 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
955 wireMockServer.stubFor(get(urlMatching(
956 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
957 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
958 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
959 .withStatus(org.apache.http.HttpStatus.SC_OK)));
961 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
962 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
963 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
964 .withStatus(org.apache.http.HttpStatus.SC_OK)));
966 wireMockServer.stubFor(get(urlMatching(
967 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
968 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
969 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
970 .withStatus(org.apache.http.HttpStatus.SC_OK)));
973 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
974 RequestReferences requestReferences = new RequestReferences();
975 requestReferences.setInstanceId("1882939");
976 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
977 expectedResponse.setRequestReferences(requestReferences);
978 uri = servInstanceuri + "v7"
979 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
980 ResponseEntity<String> response =
981 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
982 logger.debug(response.getBody());
984 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
985 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
986 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
990 public void recreateVnfInstance() throws IOException {
991 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
992 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
993 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
995 wireMockServer.stubFor(get(urlMatching(
996 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
997 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
998 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
999 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1001 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1002 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1003 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1004 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1006 wireMockServer.stubFor(get(urlMatching(
1007 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1008 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1009 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1010 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1012 // expected response
1013 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1014 RequestReferences requestReferences = new RequestReferences();
1015 requestReferences.setInstanceId("1882939");
1016 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1017 expectedResponse.setRequestReferences(requestReferences);
1018 uri = servInstanceuri + "v7"
1019 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1020 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1021 logger.debug(response.getBody());
1023 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1024 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1025 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1029 public void updateVnfInstance() throws IOException {
1030 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1031 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1032 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1034 wireMockServer.stubFor(get(urlMatching(
1035 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1036 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1037 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1038 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1040 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1041 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1042 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1043 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1045 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1046 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1048 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1049 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1051 // expected response
1052 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1053 RequestReferences requestReferences = new RequestReferences();
1054 requestReferences.setInstanceId("1882939");
1055 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1056 expectedResponse.setRequestReferences(requestReferences);
1057 uri = servInstanceuri + "v7"
1058 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1059 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1061 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1062 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1063 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1067 public void applyUpdatedConfig() throws IOException {
1068 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1069 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1070 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1073 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1074 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1076 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1077 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1079 // expected response
1080 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1081 RequestReferences requestReferences = new RequestReferences();
1082 requestReferences.setInstanceId("1882939");
1083 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1084 expectedResponse.setRequestReferences(requestReferences);
1085 uri = servInstanceuri + "v7"
1086 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1087 ResponseEntity<String> response =
1088 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1090 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1091 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1092 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1096 public void deleteVnfInstanceV5() throws IOException {
1097 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1098 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1099 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1101 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1102 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1103 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1104 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1105 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1106 // expected response
1107 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1108 RequestReferences requestReferences = new RequestReferences();
1109 requestReferences.setInstanceId("1882939");
1110 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1111 expectedResponse.setRequestReferences(requestReferences);
1112 uri = servInstanceuri + "v5"
1113 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1114 ResponseEntity<String> response =
1115 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1117 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1118 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1119 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1123 public void createVfModuleInstance() throws IOException {
1124 wireMockServer.stubFor(get(urlMatching(
1125 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1127 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1128 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1130 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1131 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1132 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1133 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1135 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1136 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1137 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1138 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1140 wireMockServer.stubFor(get(urlMatching(
1141 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1142 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1143 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1144 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1146 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1147 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1148 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1150 wireMockServer.stubFor(get(urlMatching(
1151 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1152 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1153 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1154 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1155 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1156 // expected response
1157 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1158 RequestReferences requestReferences = new RequestReferences();
1159 requestReferences.setInstanceId("1882939");
1160 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1161 expectedResponse.setRequestReferences(requestReferences);
1162 uri = servInstanceuri + "v7"
1163 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1164 ResponseEntity<String> response =
1165 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1167 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1168 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1169 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1170 assertTrue(response.getBody().contains("1882939"));
1174 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1175 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1176 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1177 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1179 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1180 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1181 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1182 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1185 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1186 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1187 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1188 .withBody(getWiremockResponseForCatalogdb(
1189 "vnfResourceCustomizationForVfModule_Response.json"))
1190 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1192 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1193 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1194 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1195 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1197 wireMockServer.stubFor(get(urlMatching(
1198 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1199 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1200 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1201 .withBody(getWiremockResponseForCatalogdb(
1202 "vfModuleCustomizationPCM_Response.json"))
1203 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1205 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1206 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1207 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1208 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1210 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1211 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1212 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1213 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1216 wireMockServer.stubFor(
1217 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1218 + "[?]vnfComponentType=vfModule&action=createInstance"))
1219 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1220 .withBody(getWiremockResponseForCatalogdb(
1221 "vnfComponentRecipeVNF_API_Response.json"))
1222 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1224 // expected response
1225 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1226 RequestReferences requestReferences = new RequestReferences();
1227 requestReferences.setInstanceId("1882939");
1228 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1229 expectedResponse.setRequestReferences(requestReferences);
1230 uri = servInstanceuri + "v6"
1231 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1232 ResponseEntity<String> response =
1233 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1234 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1235 ObjectMapper mapper = new ObjectMapper();
1236 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1237 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1241 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1242 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1244 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1246 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1247 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1248 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1249 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1252 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1253 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1254 .withBody(getWiremockResponseForCatalogdb(
1255 "vnfResourceCustomizationForVfModule_Response.json"))
1256 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1258 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1259 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1260 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1261 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1263 wireMockServer.stubFor(get(urlMatching(
1264 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1265 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1266 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1267 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1269 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1270 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1271 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1272 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1274 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1275 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1276 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1277 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1279 wireMockServer.stubFor(get(urlMatching(
1280 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1281 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1282 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1283 .withBody(getWiremockResponseForCatalogdb(
1284 "vnfComponentRecipeDeleteVfModule_Response.json"))
1285 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1287 // expected response
1288 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1289 RequestReferences requestReferences = new RequestReferences();
1290 requestReferences.setInstanceId("1882939");
1291 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1292 expectedResponse.setRequestReferences(requestReferences);
1293 uri = servInstanceuri + "v6"
1294 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1295 ResponseEntity<String> response =
1296 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1299 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1300 ObjectMapper mapper = new ObjectMapper();
1301 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1302 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1306 public void createVfModuleInstanceNoRecipe() throws IOException {
1308 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1310 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1311 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1314 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1315 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1316 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1317 .withBody(getWiremockResponseForCatalogdb(
1318 "vnfResourceCustomizationForVfModule_Response.json"))
1319 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1321 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1322 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1323 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1324 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1326 wireMockServer.stubFor(
1327 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1328 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1329 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1330 .withBody(getWiremockResponseForCatalogdb(
1331 "vfModuleCustomizationPCM_Response.json"))
1332 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1334 uri = servInstanceuri + "v6"
1335 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1336 ResponseEntity<String> response =
1337 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1339 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1340 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1341 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1345 public void replaceVfModuleInstance() throws IOException {
1346 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1347 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1348 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1351 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1352 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1353 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1354 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1355 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1357 wireMockServer.stubFor(get(urlMatching(
1358 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1359 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1360 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1361 .withBody(getWiremockResponseForCatalogdb(
1362 "vnfComponentRecipeDeleteVfModule_Response.json"))
1363 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1364 // expected response
1365 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1366 RequestReferences requestReferences = new RequestReferences();
1367 requestReferences.setInstanceId("1882939");
1368 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1369 expectedResponse.setRequestReferences(requestReferences);
1370 uri = servInstanceuri + "v7"
1371 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1372 ResponseEntity<String> response =
1373 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1375 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1376 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1377 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1381 public void updateVfModuleInstance() throws IOException {
1382 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1383 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1384 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1386 wireMockServer.stubFor(get(urlMatching(
1387 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1388 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1389 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1390 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1392 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1393 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1394 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1395 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1397 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1398 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1399 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1400 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1402 wireMockServer.stubFor(get(urlMatching(
1403 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1404 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1405 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1406 .withBody(getWiremockResponseForCatalogdb(
1407 "vnfComponentRecipe_GRAPI_Response.json"))
1408 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1410 // expected response
1411 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1412 RequestReferences requestReferences = new RequestReferences();
1413 requestReferences.setInstanceId("1882939");
1414 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1415 expectedResponse.setRequestReferences(requestReferences);
1416 uri = servInstanceuri + "v7"
1417 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1418 ResponseEntity<String> response =
1419 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1420 logger.debug(response.getBody());
1422 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1423 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1424 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1428 public void createVfModuleNoModelType() throws IOException {
1429 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1430 expectedRecord.setRequestStatus("FAILED");
1431 expectedRecord.setAction("createInstance");
1432 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1433 expectedRecord.setProgress(100L);
1434 expectedRecord.setSource("VID");
1435 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1436 expectedRecord.setLastModifiedBy("APIH");
1437 expectedRecord.setVfModuleName("testVfModule2");
1438 expectedRecord.setVfModuleModelName("serviceModel");
1439 expectedRecord.setRequestScope("vfModule");
1440 expectedRecord.setRequestAction("createInstance");
1441 expectedRecord.setRequestorId("zz9999");
1442 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1443 // VnfType is not sent in this request, should be blank in db
1444 expectedRecord.setVnfType("");
1445 uri = servInstanceuri
1446 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1448 ResponseEntity<String> response =
1449 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1451 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1455 public void inPlaceSoftwareUpdate() throws IOException {
1456 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1457 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1458 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1460 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1461 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1462 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1463 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1464 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1466 // expected response
1467 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1468 RequestReferences requestReferences = new RequestReferences();
1469 requestReferences.setInstanceId("1882939");
1470 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1471 expectedResponse.setRequestReferences(requestReferences);
1472 uri = servInstanceuri + "v7"
1473 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1474 ResponseEntity<String> response =
1475 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1477 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1478 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1479 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1483 public void deleteVfModuleInstance() throws IOException {
1484 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1485 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1486 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1489 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1490 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1491 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1492 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1493 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1495 wireMockServer.stubFor(get(urlMatching(
1496 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1497 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1498 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1499 .withBody(getWiremockResponseForCatalogdb(
1500 "vnfComponentRecipeDeleteVfModule_Response.json"))
1501 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1503 // expected response
1504 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1505 RequestReferences requestReferences = new RequestReferences();
1506 requestReferences.setInstanceId("1882939");
1507 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1508 expectedResponse.setRequestReferences(requestReferences);
1509 uri = servInstanceuri + "v7"
1510 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1511 ResponseEntity<String> response =
1512 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1514 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1515 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1516 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1520 public void deleteVfModuleNoModelInvariantId() throws IOException {
1521 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1522 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1523 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1525 wireMockServer.stubFor(get(urlMatching(
1526 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1527 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1528 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1529 .withBody(getWiremockResponseForCatalogdb(
1530 "vnfComponentRecipeDeleteVfModule_Response.json"))
1531 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1533 // expected response
1534 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1535 RequestReferences requestReferences = new RequestReferences();
1536 requestReferences.setInstanceId("1882939");
1537 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1538 expectedResponse.setRequestReferences(requestReferences);
1539 uri = servInstanceuri + "v7"
1540 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1541 ResponseEntity<String> response =
1542 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1544 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1545 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1546 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1550 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1551 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1552 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1553 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1556 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1557 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1558 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1559 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1560 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1562 wireMockServer.stubFor(get(urlMatching(
1563 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1564 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1565 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1566 .withBody(getWiremockResponseForCatalogdb(
1567 "vnfComponentRecipeDeactivate_Response.json"))
1568 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1570 // expected response
1571 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1572 RequestReferences requestReferences = new RequestReferences();
1573 requestReferences.setInstanceId("1882939");
1574 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1575 expectedResponse.setRequestReferences(requestReferences);
1576 uri = servInstanceuri + "v7"
1577 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1578 ResponseEntity<String> response =
1579 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1581 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1582 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1583 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1587 public void createVolumeGroupInstance() throws IOException {
1588 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1589 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1590 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1592 wireMockServer.stubFor(get(urlMatching(
1593 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1594 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1595 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1596 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1598 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1599 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1600 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1601 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1603 wireMockServer.stubFor(get(urlMatching(
1604 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1605 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1606 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1607 .withBody(getWiremockResponseForCatalogdb(
1608 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1609 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1611 // expected response
1612 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1613 RequestReferences requestReferences = new RequestReferences();
1614 requestReferences.setInstanceId("1882939");
1615 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1616 expectedResponse.setRequestReferences(requestReferences);
1617 uri = servInstanceuri + "v7"
1618 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1619 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1621 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1622 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1623 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1624 assertTrue(response.getBody().contains("1882939"));
1628 public void updateVolumeGroupInstance() throws IOException {
1629 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1630 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1631 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1633 wireMockServer.stubFor(get(urlMatching(
1634 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1635 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1636 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1637 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1639 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1640 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1641 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1642 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1644 wireMockServer.stubFor(get(urlMatching(
1645 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1646 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1647 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1648 .withBody(getWiremockResponseForCatalogdb(
1649 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1650 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1652 // expected response
1653 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1654 RequestReferences requestReferences = new RequestReferences();
1655 requestReferences.setInstanceId("1882939");
1656 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1657 expectedResponse.setRequestReferences(requestReferences);
1658 uri = servInstanceuri + "v7"
1659 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1660 ResponseEntity<String> response =
1661 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1663 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1664 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1665 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1669 public void deleteVolumeGroupInstance() throws IOException {
1670 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1671 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1672 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1674 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1675 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1676 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1678 wireMockServer.stubFor(get(urlMatching(
1679 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1680 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1681 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1682 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1684 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1685 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1686 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1687 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1689 wireMockServer.stubFor(get(urlMatching(
1690 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1691 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1692 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1693 .withBody(getWiremockResponseForCatalogdb(
1694 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1695 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1697 // expected response
1698 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1699 RequestReferences requestReferences = new RequestReferences();
1700 requestReferences.setInstanceId("1882939");
1701 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1702 expectedResponse.setRequestReferences(requestReferences);
1703 uri = servInstanceuri + "v7"
1704 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1705 ResponseEntity<String> response =
1706 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1708 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1709 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1710 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1714 public void createNetworkInstance() throws IOException {
1715 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1717 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1719 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1720 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1721 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1722 .withStatus(HttpStatus.SC_OK)));
1724 wireMockServer.stubFor(
1725 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1726 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1727 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1728 .withStatus(HttpStatus.SC_OK)));
1730 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1731 + "modelName=GR-API-DEFAULT&action=createInstance"))
1732 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1733 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1734 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1736 // expected response
1737 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1738 RequestReferences requestReferences = new RequestReferences();
1739 requestReferences.setInstanceId("1882939");
1740 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1741 expectedResponse.setRequestReferences(requestReferences);
1742 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1743 ResponseEntity<String> response =
1744 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1746 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1747 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1748 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1752 public void updateNetworkInstance() throws IOException {
1753 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1754 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1755 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1757 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1758 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1759 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1760 .withStatus(HttpStatus.SC_OK)));
1762 wireMockServer.stubFor(
1763 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1764 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1765 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1766 .withStatus(HttpStatus.SC_OK)));
1768 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1769 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1770 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1771 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1772 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1773 // expected response
1774 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1775 RequestReferences requestReferences = new RequestReferences();
1776 requestReferences.setInstanceId("1882939");
1777 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1778 expectedResponse.setRequestReferences(requestReferences);
1779 uri = servInstanceuri + "v7"
1780 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1781 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1783 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1784 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1785 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1786 assertTrue(response.getBody().contains("1882939"));
1790 public void deleteNetworkInstance() throws IOException {
1791 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1793 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1795 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1796 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1797 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1798 .withStatus(HttpStatus.SC_OK)));
1800 wireMockServer.stubFor(
1801 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1802 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1803 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1804 .withStatus(HttpStatus.SC_OK)));
1806 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1807 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1808 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1809 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1810 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1812 // expected response
1813 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1814 RequestReferences requestReferences = new RequestReferences();
1815 requestReferences.setInstanceId("1882939");
1816 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1817 expectedResponse.setRequestReferences(requestReferences);
1818 uri = servInstanceuri + "v7"
1819 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1820 ResponseEntity<String> response =
1821 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1823 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1824 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1825 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1829 public void deleteNetworkInstanceNoReqParams() throws IOException {
1830 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1831 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1832 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1834 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1835 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1836 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1837 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1838 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1841 // expected response
1842 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1843 RequestReferences requestReferences = new RequestReferences();
1844 requestReferences.setInstanceId("1882939");
1845 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1846 expectedResponse.setRequestReferences(requestReferences);
1847 uri = servInstanceuri + "v6"
1848 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1849 ResponseEntity<String> response =
1850 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1852 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1853 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1854 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1858 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1860 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1861 expectedRecord.setRequestStatus("FAILED");
1862 expectedRecord.setStatusMessage("Error mapping request: ");
1863 expectedRecord.setProgress(100L);
1864 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1865 expectedRecord.setLastModifiedBy("APIH");
1866 expectedRecord.setRequestScope("network");
1867 expectedRecord.setRequestAction("deleteInstance");
1868 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1870 uri = servInstanceuri + "v6"
1871 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1872 ResponseEntity<String> response =
1873 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1877 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1881 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1882 uri = servInstanceuri + "v5"
1883 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1884 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1886 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1890 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1891 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1892 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1893 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1895 ServiceRecipe serviceRecipe = new ServiceRecipe();
1896 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1897 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1898 serviceRecipe.setAction(Action.createInstance.toString());
1899 serviceRecipe.setId(1);
1900 serviceRecipe.setRecipeTimeout(180);
1901 Service defaultService = new Service();
1902 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1904 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1905 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1906 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1908 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1909 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1910 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1912 uri = servInstanceuri + "v7" + "/serviceInstances";
1913 ResponseEntity<String> response =
1914 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1916 // expected response
1917 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1918 RequestReferences requestReferences = new RequestReferences();
1919 requestReferences.setInstanceId("1882939");
1920 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1921 expectedResponse.setRequestReferences(requestReferences);
1923 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1924 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1925 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1929 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1930 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1931 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1932 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1934 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1935 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1936 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1937 .withStatus(HttpStatus.SC_OK)));
1939 wireMockServer.stubFor(
1940 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1941 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1942 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1943 .withStatus(HttpStatus.SC_OK)));
1945 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1946 + "modelName=GR-API-DEFAULT&action=createInstance"))
1947 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1948 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1949 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1951 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1952 ResponseEntity<String> response =
1953 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1955 // expected response
1956 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1957 RequestReferences requestReferences = new RequestReferences();
1958 requestReferences.setInstanceId("1882939");
1959 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1960 expectedResponse.setRequestReferences(requestReferences);
1962 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1963 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1964 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1968 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1969 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1970 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1971 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1973 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1974 ResponseEntity<String> response =
1975 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1977 // expected response
1978 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1979 RequestReferences requestReferences = new RequestReferences();
1980 requestReferences.setInstanceId("1882939");
1981 expectedResponse.setRequestReferences(requestReferences);
1983 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1987 public void createNetworkInstanceTestApiGrApi() throws IOException {
1988 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1989 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1990 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1992 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1993 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1994 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1995 .withStatus(HttpStatus.SC_OK)));
1997 wireMockServer.stubFor(
1998 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1999 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2000 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2001 .withStatus(HttpStatus.SC_OK)));
2003 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2004 + "modelName=GR-API-DEFAULT&action=createInstance"))
2005 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2006 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2007 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2009 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2010 ResponseEntity<String> response =
2011 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2013 // expected response
2014 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2015 RequestReferences requestReferences = new RequestReferences();
2016 requestReferences.setInstanceId("1882939");
2017 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2018 expectedResponse.setRequestReferences(requestReferences);
2020 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2021 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2022 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2026 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2027 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2028 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2029 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2031 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2032 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2033 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2034 .withStatus(HttpStatus.SC_OK)));
2036 wireMockServer.stubFor(
2037 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2038 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2039 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2040 .withStatus(HttpStatus.SC_OK)));
2042 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2043 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2044 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2045 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2046 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2048 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2049 ResponseEntity<String> response =
2050 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2052 // expected response
2053 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2054 RequestReferences requestReferences = new RequestReferences();
2055 requestReferences.setInstanceId("1882939");
2056 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2057 expectedResponse.setRequestReferences(requestReferences);
2059 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2060 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2061 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2065 public void activateServiceInstanceRequestStatus() throws IOException {
2066 ServiceRecipe serviceRecipe = new ServiceRecipe();
2067 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2068 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2069 serviceRecipe.setAction(Action.createInstance.toString());
2070 serviceRecipe.setId(1);
2071 serviceRecipe.setRecipeTimeout(180);
2072 Service defaultService = new Service();
2073 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2075 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2076 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2077 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2079 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2081 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2083 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2084 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2085 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2088 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2089 RequestReferences requestReferences = new RequestReferences();
2090 requestReferences.setInstanceId("1882939");
2091 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2092 expectedResponse.setRequestReferences(requestReferences);
2093 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2094 ResponseEntity<String> response =
2095 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2097 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2098 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2099 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2103 public void invalidRequestId() throws IOException {
2104 String illegalRequestId = "1234";
2105 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2106 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2107 uri = servInstanceuri + "v5/serviceInstances";
2108 ResponseEntity<String> response =
2109 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2111 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2112 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2116 public void invalidBPELResponse() throws IOException {
2118 ServiceRecipe serviceRecipe = new ServiceRecipe();
2119 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2120 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2121 serviceRecipe.setAction(Action.createInstance.toString());
2122 serviceRecipe.setId(1);
2123 serviceRecipe.setRecipeTimeout(180);
2124 Service defaultService = new Service();
2125 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2127 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2128 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2129 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2131 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2132 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2133 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2135 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2136 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2137 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2139 uri = servInstanceuri + "v5/serviceInstances";
2140 ResponseEntity<String> response =
2141 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2143 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2144 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2145 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2146 realResponse.getServiceException().getText());
2150 public void unauthorizedBPELResponse() throws IOException {
2152 ServiceRecipe serviceRecipe = new ServiceRecipe();
2153 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2154 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2155 serviceRecipe.setAction(Action.createInstance.toString());
2156 serviceRecipe.setId(1);
2157 serviceRecipe.setRecipeTimeout(180);
2158 Service defaultService = new Service();
2159 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2161 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2162 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2163 .withBodyFile("Camunda/UnauthorizedResponse.json")
2164 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2166 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2167 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2168 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2170 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2171 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2172 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2174 uri = servInstanceuri + "v5/serviceInstances";
2175 ResponseEntity<String> response =
2176 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2178 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2179 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2180 assertEquals("Exception caught mapping Camunda JSON response to object",
2181 realResponse.getServiceException().getText());
2185 public void invalidBPELResponse2() throws IOException {
2187 ServiceRecipe serviceRecipe = new ServiceRecipe();
2188 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2189 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2190 serviceRecipe.setAction(Action.createInstance.toString());
2191 serviceRecipe.setId(1);
2192 serviceRecipe.setRecipeTimeout(180);
2193 Service defaultService = new Service();
2194 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2196 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2197 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2198 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2200 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2201 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2202 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2204 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2205 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2206 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2207 uri = servInstanceuri + "v5/serviceInstances";
2208 ResponseEntity<String> response =
2209 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2211 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2212 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2213 assertTrue(realResponse.getServiceException().getText()
2214 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2218 public void createMacroServiceInstance() throws IOException {
2219 ServiceRecipe serviceRecipe = new ServiceRecipe();
2220 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2221 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2222 serviceRecipe.setAction(Action.createInstance.toString());
2223 serviceRecipe.setId(1);
2224 serviceRecipe.setRecipeTimeout(180);
2225 Service defaultService = new Service();
2226 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2228 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2229 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2230 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2232 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2233 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2234 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2236 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2237 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2238 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2240 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2241 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2242 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2245 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2246 RequestReferences requestReferences = new RequestReferences();
2247 requestReferences.setInstanceId("1882939");
2248 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2249 expectedResponse.setRequestReferences(requestReferences);
2250 uri = servInstanceuri + "v5";
2251 ResponseEntity<String> response =
2252 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2255 assertEquals(404, response.getStatusCode().value());
2259 public void testUserParams() throws IOException {
2260 ObjectMapper mapper = new ObjectMapper();
2261 ServiceInstancesRequest request =
2262 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2263 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2264 String userParamsTxt = inputStream("/userParams.txt");
2266 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2267 System.out.println(userParams);
2268 assertTrue(userParams.size() > 0);
2269 assertTrue(userParams.get(0).containsKey("name"));
2270 assertTrue(userParams.get(0).containsKey("value"));
2271 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2275 public void testConfigureCloudConfig() throws IOException {
2276 ObjectMapper mapper = new ObjectMapper();
2277 ServiceInstancesRequest request =
2278 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2279 CloudConfiguration cloudConfig =
2280 servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2282 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2283 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2287 public void testMapToLegacyRequest() throws IOException {
2288 ObjectMapper mapper = new ObjectMapper();
2289 ServiceInstancesRequest request =
2290 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2291 ServiceInstancesRequest expected =
2292 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2293 servInstances.mapToLegacyRequest(request.getRequestDetails());
2294 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2295 assertThat(request, sameBeanAs(expected));
2299 public void scaleOutVfModule() throws IOException {
2300 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2301 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2302 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2304 wireMockServer.stubFor(get(urlMatching(
2305 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2306 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2307 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2308 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2310 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2311 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2312 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2313 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2315 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2316 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2317 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2318 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2321 wireMockServer.stubFor(get(urlMatching(
2322 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2323 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2324 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2325 .withBody(getWiremockResponseForCatalogdb(
2326 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2327 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2329 wireMockServer.stubFor(get(urlMatching(
2330 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2331 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2332 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2333 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2335 // expected response
2336 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2337 RequestReferences requestReferences = new RequestReferences();
2338 requestReferences.setInstanceId("1882939");
2339 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2340 expectedResponse.setRequestReferences(requestReferences);
2341 uri = servInstanceuri + "v7"
2342 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2343 ResponseEntity<String> response =
2344 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2346 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2347 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2348 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2349 assertTrue(response.getBody().contains("1882939"));
2353 public void createServiceInstanceBadResponse() throws IOException {
2354 ServiceRecipe serviceRecipe = new ServiceRecipe();
2355 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2356 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2357 serviceRecipe.setAction(Action.createInstance.toString());
2358 serviceRecipe.setId(1);
2359 serviceRecipe.setRecipeTimeout(180);
2360 Service defaultService = new Service();
2361 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2363 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2365 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2367 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2368 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2369 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2371 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2372 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2373 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2375 uri = servInstanceuri + "v5/serviceInstances";
2376 ResponseEntity<String> response =
2377 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2379 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2380 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2381 assertEquals("Exception caught mapping Camunda JSON response to object",
2382 realResponse.getServiceException().getText());
2386 public void createServiceInstanceDuplicateError() throws IOException {
2387 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2388 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2389 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2391 uri = servInstanceuri + "v5/serviceInstances";
2392 ResponseEntity<String> response =
2393 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2395 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2396 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2398 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2399 realResponse.getServiceException().getText());
2403 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2404 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2405 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2406 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2407 .withStatus(HttpStatus.SC_ACCEPTED)));
2408 wireMockServer.stubFor(get(
2409 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2410 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2411 .withBodyFile("Camunda/HistoryCheckResponse.json")
2412 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2414 uri = servInstanceuri + "v5/serviceInstances";
2415 ResponseEntity<String> response =
2416 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2418 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2419 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2421 "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.",
2422 realResponse.getServiceException().getText());
2426 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2427 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2428 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2429 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2430 .withStatus(HttpStatus.SC_ACCEPTED)));
2431 wireMockServer.stubFor(get(
2432 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2433 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2434 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2436 uri = servInstanceuri + "v5/serviceInstances";
2437 ResponseEntity<String> response =
2438 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2440 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2441 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2443 "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",
2444 realResponse.getServiceException().getText());
2448 public void createServiceInstanceDuplicate() throws IOException {
2449 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2450 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2451 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2453 uri = servInstanceuri + "v5/serviceInstances";
2454 ResponseEntity<String> response =
2455 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2457 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2458 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2460 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2461 realResponse.getServiceException().getText());
2465 public void createServiceInstanceSaveError() throws IOException {
2466 ServiceRecipe serviceRecipe = new ServiceRecipe();
2467 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2468 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2469 serviceRecipe.setAction(Action.createInstance.toString());
2470 serviceRecipe.setId(1);
2471 serviceRecipe.setRecipeTimeout(180);
2472 Service defaultService = new Service();
2473 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2474 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2476 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2477 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2478 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2479 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2481 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2482 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2483 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2485 uri = servInstanceuri + "v5/serviceInstances";
2486 ResponseEntity<String> response =
2487 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2489 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2490 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2492 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2493 realResponse.getServiceException().getText());
2497 public void createPortConfigurationSaveError() throws IOException {
2498 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2499 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2500 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2501 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2502 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2503 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2505 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2506 ResponseEntity<String> response =
2507 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2509 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2510 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2512 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2513 realResponse.getServiceException().getText());
2517 public void createPortConfigDbUpdateError() throws IOException {
2518 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2519 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2520 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2522 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2523 ResponseEntity<String> response =
2524 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2526 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2527 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2529 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2530 realResponse.getServiceException().getText());
2534 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2535 TestAppender.events.clear();
2536 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2537 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2538 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2540 wireMockServer.stubFor(get(urlMatching(
2541 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2542 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2543 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2544 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2546 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2547 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2548 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2549 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2551 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2552 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2553 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2554 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2555 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2556 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2558 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2559 RequestReferences requestReferences = new RequestReferences();
2560 requestReferences.setInstanceId("1882939");
2561 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2562 expectedResponse.setRequestReferences(requestReferences);
2563 uri = servInstanceuri
2564 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2565 ResponseEntity<String> response =
2566 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2568 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2569 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2570 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2571 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2573 for (ILoggingEvent logEvent : TestAppender.events) {
2574 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging")
2575 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
2576 Map<String, String> mdc = logEvent.getMDCPropertyMap();
2577 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2578 assertEquals("VID", mdc.get(PARTNERNAME));
2584 public void createInstanceGroup() throws IOException {
2585 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2586 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2587 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2590 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2591 RequestReferences requestReferences = new RequestReferences();
2592 requestReferences.setInstanceId("1882939");
2593 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2594 expectedResponse.setRequestReferences(requestReferences);
2595 uri = servInstanceuri + "/v7/instanceGroups";
2596 ResponseEntity<String> response =
2597 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2600 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2601 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2602 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2606 public void deleteInstanceGroup() throws IOException {
2607 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2608 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2609 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2612 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2613 RequestReferences requestReferences = new RequestReferences();
2614 requestReferences.setInstanceId("1882939");
2615 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2616 expectedResponse.setRequestReferences(requestReferences);
2617 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2618 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2621 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2622 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2623 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2627 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2628 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2629 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2631 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2632 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2633 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2637 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2638 HttpHeaders noPartnerHeaders = new HttpHeaders();
2639 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2640 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2641 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2642 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2644 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2645 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2646 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2650 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2651 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2652 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2653 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2655 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2656 RequestReferences requestReferences = new RequestReferences();
2657 requestReferences.setInstanceId("1882939");
2658 expectedResponse.setRequestReferences(requestReferences);
2659 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2660 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2663 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2664 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2665 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2669 public void addMembers() throws IOException {
2670 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2671 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2672 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2674 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2675 RequestReferences requestReferences = new RequestReferences();
2676 requestReferences.setInstanceId("1882939");
2677 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2678 expectedResponse.setRequestReferences(requestReferences);
2679 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2680 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2683 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2684 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2685 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2689 public void removeMembers() throws IOException {
2690 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2691 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2692 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2694 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2695 RequestReferences requestReferences = new RequestReferences();
2696 requestReferences.setInstanceId("1882939");
2697 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2698 expectedResponse.setRequestReferences(requestReferences);
2699 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2700 ResponseEntity<String> response =
2701 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2704 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2705 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2706 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2710 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2711 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2712 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2713 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2715 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2717 .withStatus(HttpStatus.SC_NOT_FOUND)));
2719 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2720 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2721 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2722 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2723 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2725 // expected response
2726 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2727 RequestReferences requestReferences = new RequestReferences();
2728 requestReferences.setInstanceId("1882939");
2729 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2730 expectedResponse.setRequestReferences(requestReferences);
2731 uri = servInstanceuri + "v7"
2732 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2733 ResponseEntity<String> response =
2734 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2736 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2737 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2738 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2742 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2743 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2744 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2745 .withStatus(HttpStatus.SC_NOT_FOUND)));
2747 uri = servInstanceuri + "v7"
2748 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2749 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2751 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2752 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2753 assertEquals(realResponse.getServiceException().getText(),
2754 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2758 public void setServiceTypeTestALaCarte() throws JsonProcessingException {
2759 String requestScope = ModelType.service.toString();
2760 Boolean aLaCarteFlag = true;
2761 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2762 RequestDetails requestDetails = new RequestDetails();
2763 RequestInfo requestInfo = new RequestInfo();
2764 requestInfo.setSource("VID");
2765 requestDetails.setRequestInfo(requestInfo);
2766 sir.setRequestDetails(requestDetails);
2767 Service defaultService = new Service();
2768 defaultService.setServiceType("testServiceTypeALaCarte");
2770 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2771 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2772 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2774 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2775 assertEquals(serviceType, "testServiceTypeALaCarte");
2779 public void setServiceTypeTest() throws JsonProcessingException {
2780 String requestScope = ModelType.service.toString();
2781 Boolean aLaCarteFlag = false;
2782 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2783 RequestDetails requestDetails = new RequestDetails();
2784 RequestInfo requestInfo = new RequestInfo();
2785 ModelInfo modelInfo = new ModelInfo();
2786 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2787 requestInfo.setSource("VID");
2788 requestDetails.setModelInfo(modelInfo);
2789 requestDetails.setRequestInfo(requestInfo);
2790 sir.setRequestDetails(requestDetails);
2791 Service defaultService = new Service();
2792 defaultService.setServiceType("testServiceType");
2794 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2795 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2796 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2798 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2799 assertEquals(serviceType, "testServiceType");
2803 public void setServiceTypeTestDefault() throws JsonProcessingException {
2804 String requestScope = ModelType.service.toString();
2805 Boolean aLaCarteFlag = false;
2806 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2807 RequestDetails requestDetails = new RequestDetails();
2808 RequestInfo requestInfo = new RequestInfo();
2809 ModelInfo modelInfo = new ModelInfo();
2810 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2811 requestInfo.setSource("VID");
2812 requestDetails.setModelInfo(modelInfo);
2813 requestDetails.setRequestInfo(requestInfo);
2814 sir.setRequestDetails(requestDetails);
2815 Service defaultService = new Service();
2816 defaultService.setServiceType("testServiceType");
2818 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2819 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2820 .withStatus(HttpStatus.SC_NOT_FOUND)));
2821 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2822 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2823 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2825 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2826 assertEquals(serviceType, "testServiceType");
2830 public void setServiceTypeTestNetwork() throws JsonProcessingException {
2831 String requestScope = ModelType.network.toString();
2832 Boolean aLaCarteFlag = null;
2833 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2834 RequestDetails requestDetails = new RequestDetails();
2835 RequestInfo requestInfo = new RequestInfo();
2836 ModelInfo modelInfo = new ModelInfo();
2837 modelInfo.setModelName("networkModelName");
2838 requestInfo.setSource("VID");
2839 requestDetails.setModelInfo(modelInfo);
2840 requestDetails.setRequestInfo(requestInfo);
2841 sir.setRequestDetails(requestDetails);
2843 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2844 assertEquals(serviceType, "networkModelName");
2848 public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
2849 String requestScope = "instanceGroup";
2850 ServiceInstancesRequest sir =
2851 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
2852 assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
2853 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2857 public void setServiceInstanceIdTest() {
2858 String requestScope = "vnf";
2859 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2860 sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2861 assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
2862 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2866 public void setServiceInstanceIdReturnNullTest() {
2867 String requestScope = "vnf";
2868 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2869 assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2873 public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
2874 wireMockServer.stubFor(get(
2875 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2876 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2877 .withBodyFile("Camunda/HistoryCheckResponse.json")
2878 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2880 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2881 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2882 boolean inProgress = false;
2883 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2884 assertTrue(inProgress);
2888 public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
2889 wireMockServer.stubFor(get(
2890 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2891 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2892 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
2894 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2895 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2896 boolean inProgress = false;
2897 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2898 assertFalse(inProgress);
2902 public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException {
2903 wireMockServer.stubFor(get(
2904 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2905 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2906 .withBodyFile("Camunda/HistoryCheckResponseCompleted.json")
2907 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2909 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2910 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2911 boolean inProgress = false;
2912 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2913 assertFalse(inProgress);
2917 public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
2918 String replaceVfModule = inputStream("/ReplaceVfModule.json");
2919 ObjectMapper mapper = new ObjectMapper();
2920 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2921 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2922 assertEquals(Action.replaceInstance, action);
2926 public void handleReplaceInstance_retainAssignments_Test()
2927 throws JsonParseException, JsonMappingException, IOException {
2928 String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
2929 ObjectMapper mapper = new ObjectMapper();
2930 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2931 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2932 assertEquals(Action.replaceInstanceRetainAssignments, action);