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.assertNotNull;
32 import static org.junit.Assert.assertThat;
33 import static org.junit.Assert.assertTrue;
34 import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
35 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
36 import static org.onap.so.logger.MdcConstants.CLIENT_ID;
37 import static org.onap.so.logger.MdcConstants.ENDTIME;
38 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
39 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
40 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
41 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
42 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
43 import static org.onap.so.logger.MdcConstants.STATUSCODE;
44 import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
46 import java.io.IOException;
47 import java.net.MalformedURLException;
49 import java.nio.file.Files;
50 import java.nio.file.Paths;
51 import java.util.List;
53 import javax.ws.rs.core.MediaType;
54 import javax.ws.rs.core.Response;
55 import org.apache.http.HttpStatus;
56 import org.junit.Before;
57 import org.junit.Test;
58 import org.mockito.Mockito;
59 import org.onap.logging.ref.slf4j.ONAPLogConstants;
60 import org.onap.so.db.catalog.beans.Service;
61 import org.onap.so.db.catalog.beans.ServiceRecipe;
62 import org.onap.so.db.request.beans.InfraActiveRequests;
63 import org.onap.so.logger.HttpHeadersConstants;
64 import org.onap.so.serviceinstancebeans.CloudConfiguration;
65 import org.onap.so.serviceinstancebeans.RequestError;
66 import org.onap.so.serviceinstancebeans.RequestParameters;
67 import org.onap.so.serviceinstancebeans.RequestReferences;
68 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
69 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
70 import org.springframework.beans.factory.annotation.Autowired;
71 import org.springframework.beans.factory.annotation.Value;
72 import org.springframework.http.HttpEntity;
73 import org.springframework.http.HttpHeaders;
74 import org.springframework.http.HttpMethod;
75 import org.springframework.http.ResponseEntity;
76 import org.springframework.util.ResourceUtils;
77 import org.springframework.web.util.UriComponentsBuilder;
78 import com.fasterxml.jackson.annotation.JsonInclude.Include;
79 import com.fasterxml.jackson.core.JsonParseException;
80 import com.fasterxml.jackson.core.JsonProcessingException;
81 import com.fasterxml.jackson.databind.DeserializationFeature;
82 import com.fasterxml.jackson.databind.JsonMappingException;
83 import com.fasterxml.jackson.databind.ObjectMapper;
84 import com.github.tomakehurst.wiremock.http.Fault;
85 import ch.qos.logback.classic.spi.ILoggingEvent;
88 public class ServiceInstancesTest extends BaseTest {
90 private final ObjectMapper mapper = new ObjectMapper();
91 private ObjectMapper errorMapper = new ObjectMapper();
94 private ServiceInstances servInstances;
96 @Value("${wiremock.server.port}")
97 private String wiremockPort;
99 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
100 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
102 private URL selfLink;
103 private URL initialUrl;
104 private int initialPort;
105 private HttpHeaders headers;
108 public void beforeClass() {
109 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
110 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
111 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
113 headers = new HttpHeaders();
114 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
115 headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
116 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
117 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
118 headers.set(CLIENT_ID, "VID");
119 headers.set(REQUESTOR_ID, "xxxxxx");
120 try { // generate one-time port number to avoid RANDOM port number later.
121 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
122 initialPort = initialUrl.getPort();
123 } catch (MalformedURLException e) {
126 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*")).willReturn(aResponse()
127 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
128 Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
131 public String inputStream(String JsonInput) throws IOException {
132 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
133 return new String(Files.readAllBytes(Paths.get(JsonInput)));
136 private URL createExpectedSelfLink(String version, String requestId) {
137 System.out.println("createdUrl: " + initialUrl.toString());
139 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
140 } catch (MalformedURLException e) {
146 private String getWiremockResponseForCatalogdb(String file) {
148 File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
149 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
150 "localhost:" + wiremockPort);
151 } catch (IOException e) {
158 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
159 HttpHeaders headers) {
161 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
162 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
164 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
165 headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
168 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
170 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
172 return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
175 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
176 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
180 public void createServiceInstanceVIDDefault() throws IOException {
181 TestAppender.events.clear();
183 ServiceRecipe serviceRecipe = new ServiceRecipe();
184 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
185 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
186 serviceRecipe.setAction(Action.createInstance.toString());
187 serviceRecipe.setId(1);
188 serviceRecipe.setRecipeTimeout(180);
189 Service defaultService = new Service();
190 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
193 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
194 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
195 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
197 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
198 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
199 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
201 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
202 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
203 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
206 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
207 RequestReferences requestReferences = new RequestReferences();
208 requestReferences.setInstanceId("1882939");
209 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
210 expectedResponse.setRequestReferences(requestReferences);
211 uri = servInstanceuri + "v5/serviceInstances";
212 ResponseEntity<String> response =
213 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
216 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
217 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
218 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
222 for (ILoggingEvent logEvent : TestAppender.events)
223 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
224 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
225 Map<String, String> mdc = logEvent.getMDCPropertyMap();
226 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
227 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
228 assertNotNull(mdc.get(INVOCATION_ID));
229 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
230 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
231 assertEquals("INPROGRESS", mdc.get(STATUSCODE));
232 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
233 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
234 Map<String, String> mdc = logEvent.getMDCPropertyMap();
235 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
236 assertNotNull(mdc.get(ENDTIME));
237 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
238 assertNotNull(mdc.get(INVOCATION_ID));
239 assertEquals("202", mdc.get(RESPONSECODE));
240 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
241 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
242 assertEquals("COMPLETE", mdc.get(STATUSCODE));
243 assertNotNull(mdc.get(RESPONSEDESC));
244 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
245 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
246 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
251 public void createServiceInstanceServiceInstancesUri() throws IOException {
252 ServiceRecipe serviceRecipe = new ServiceRecipe();
253 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
254 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
255 serviceRecipe.setAction(Action.createInstance.toString());
256 serviceRecipe.setId(1);
257 serviceRecipe.setRecipeTimeout(180);
258 Service defaultService = new Service();
259 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
261 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
262 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
263 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
266 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
267 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
268 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
270 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
272 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
274 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
275 RequestReferences requestReferences = new RequestReferences();
276 requestReferences.setInstanceId("1882939");
277 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
278 expectedResponse.setRequestReferences(requestReferences);
279 uri = servInstanceUriPrev7 + "v5";
280 ResponseEntity<String> response =
281 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
284 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
285 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
286 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
290 public void createServiceInstanceBpelStatusError() throws IOException {
291 ServiceRecipe serviceRecipe = new ServiceRecipe();
292 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
293 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
294 serviceRecipe.setAction(Action.createInstance.toString());
295 serviceRecipe.setId(1);
296 serviceRecipe.setRecipeTimeout(180);
297 Service defaultService = new Service();
298 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
301 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
302 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
303 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
306 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
307 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
308 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
310 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
311 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
312 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
314 uri = servInstanceuri + "v5/serviceInstances";
315 ResponseEntity<String> response =
316 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
318 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
322 public void createServiceInstanceBadGateway() throws IOException {
323 ServiceRecipe serviceRecipe = new ServiceRecipe();
324 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
325 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
326 serviceRecipe.setAction(Action.createInstance.toString());
327 serviceRecipe.setId(1);
328 serviceRecipe.setRecipeTimeout(180);
329 Service defaultService = new Service();
330 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
332 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
333 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
335 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
336 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
337 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
339 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
340 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
341 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
343 uri = servInstanceuri + "v5/serviceInstances";
344 ResponseEntity<String> response =
345 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
347 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
351 public void createServiceInstanceEmptyResponse() throws IOException {
352 ServiceRecipe serviceRecipe = new ServiceRecipe();
353 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
354 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
355 serviceRecipe.setAction(Action.createInstance.toString());
356 serviceRecipe.setId(1);
357 serviceRecipe.setRecipeTimeout(180);
358 Service defaultService = new Service();
359 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
361 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
362 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
364 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
365 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
366 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
368 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
369 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
370 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
372 uri = servInstanceuri + "v5/serviceInstances";
373 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
375 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
379 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
380 TestAppender.events.clear();
381 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
382 HttpHeaders requestIDheaders = new HttpHeaders();
383 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
384 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
385 HttpMethod.POST, requestIDheaders);
387 Service defaultService = new Service();
388 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
390 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
391 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
392 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
395 wireMockServer.stubFor(get(urlMatching(
396 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
397 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
398 .withStatus(HttpStatus.SC_NOT_FOUND)));
400 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
404 public void activateServiceInstanceNoRecipe() throws IOException {
405 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
406 Service defaultService = new Service();
407 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
408 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
409 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
410 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
412 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
413 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
415 ResponseEntity<String> response =
416 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
418 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
422 public void activateServiceInstance() throws IOException {
423 ServiceRecipe serviceRecipe = new ServiceRecipe();
424 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
425 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
426 serviceRecipe.setAction(Action.createInstance.toString());
427 serviceRecipe.setId(1);
428 serviceRecipe.setRecipeTimeout(180);
429 Service defaultService = new Service();
430 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
432 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
433 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
434 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
436 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
437 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
438 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
440 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
441 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
442 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
444 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
445 RequestReferences requestReferences = new RequestReferences();
446 requestReferences.setInstanceId("1882939");
447 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
448 expectedResponse.setRequestReferences(requestReferences);
449 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
450 ResponseEntity<String> response =
451 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
453 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
454 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
455 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
459 public void deactivateServiceInstance() throws IOException {
461 ServiceRecipe serviceRecipe = new ServiceRecipe();
462 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
463 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
464 serviceRecipe.setAction(Action.createInstance.toString());
465 serviceRecipe.setId(1);
466 serviceRecipe.setRecipeTimeout(180);
467 Service defaultService = new Service();
468 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
470 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
471 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
472 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
474 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
476 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
478 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
479 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
480 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
482 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
483 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
484 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
487 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
488 RequestReferences requestReferences = new RequestReferences();
489 requestReferences.setInstanceId("1882939");
490 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
491 expectedResponse.setRequestReferences(requestReferences);
492 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
493 ResponseEntity<String> response =
494 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
496 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
497 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
498 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
502 public void deleteServiceInstance() throws IOException {
503 ServiceRecipe serviceRecipe = new ServiceRecipe();
504 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
505 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
506 serviceRecipe.setAction(Action.createInstance.toString());
507 serviceRecipe.setId(1);
508 serviceRecipe.setRecipeTimeout(180);
509 Service defaultService = new Service();
510 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
512 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
513 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
514 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
516 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
517 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
518 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
520 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
522 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
524 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
526 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
528 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
529 RequestReferences requestReferences = new RequestReferences();
530 requestReferences.setInstanceId("1882939");
531 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
532 expectedResponse.setRequestReferences(requestReferences);
533 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
534 ResponseEntity<String> response =
535 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
537 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
538 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
539 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
543 public void assignServiceInstance() throws IOException {
544 ServiceRecipe serviceRecipe = new ServiceRecipe();
545 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
546 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
547 serviceRecipe.setAction(Action.createInstance.toString());
548 serviceRecipe.setId(1);
549 serviceRecipe.setRecipeTimeout(180);
550 Service defaultService = new Service();
551 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
553 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
554 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
555 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
557 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
558 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
559 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
561 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
562 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
563 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
565 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
566 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
567 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
569 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
570 RequestReferences requestReferences = new RequestReferences();
571 requestReferences.setInstanceId("1882939");
572 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
573 expectedResponse.setRequestReferences(requestReferences);
574 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
575 ResponseEntity<String> response =
576 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
578 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
579 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
580 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
584 public void unassignServiceInstance() throws IOException {
585 ServiceRecipe serviceRecipe = new ServiceRecipe();
586 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
587 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
588 serviceRecipe.setAction(Action.createInstance.toString());
589 serviceRecipe.setId(1);
590 serviceRecipe.setRecipeTimeout(180);
591 Service defaultService = new Service();
592 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
594 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
596 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
598 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
599 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
600 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
602 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
604 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
606 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
607 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
608 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
610 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
611 RequestReferences requestReferences = new RequestReferences();
612 requestReferences.setInstanceId("1882939");
613 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
614 expectedResponse.setRequestReferences(requestReferences);
615 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
616 ResponseEntity<String> response =
617 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
619 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
620 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
621 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
625 public void createPortConfiguration() throws IOException {
626 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
627 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
628 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
630 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
631 RequestReferences requestReferences = new RequestReferences();
632 requestReferences.setInstanceId("1882939");
633 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
634 expectedResponse.setRequestReferences(requestReferences);
635 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
636 ResponseEntity<String> response =
637 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
639 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
640 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
641 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
642 assertTrue(response.getBody().contains("1882939"));
646 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
647 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
648 ResponseEntity<String> response =
649 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
651 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
655 public void deletePortConfiguration() throws IOException {
656 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
657 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
658 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
661 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
662 RequestReferences requestReferences = new RequestReferences();
663 requestReferences.setInstanceId("1882939");
664 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
665 expectedResponse.setRequestReferences(requestReferences);
666 uri = servInstanceuri + "v7"
667 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
668 ResponseEntity<String> response =
669 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
671 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
672 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
673 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
677 public void enablePort() throws IOException {
678 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
679 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
680 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
682 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
683 RequestReferences requestReferences = new RequestReferences();
684 requestReferences.setInstanceId("1882939");
685 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
686 expectedResponse.setRequestReferences(requestReferences);
687 uri = servInstanceuri + "v7"
688 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
689 ResponseEntity<String> response =
690 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
692 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
693 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
694 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
698 public void disablePort() throws IOException {
699 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
700 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
701 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
703 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
704 RequestReferences requestReferences = new RequestReferences();
705 requestReferences.setInstanceId("1882939");
706 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
707 expectedResponse.setRequestReferences(requestReferences);
708 uri = servInstanceuri + "v7"
709 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
710 ResponseEntity<String> response =
711 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
713 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
714 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
715 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
719 public void activatePort() throws IOException {
720 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
721 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
722 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
724 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
725 RequestReferences requestReferences = new RequestReferences();
726 requestReferences.setInstanceId("1882939");
727 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
728 expectedResponse.setRequestReferences(requestReferences);
729 uri = servInstanceuri + "v7"
730 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
731 ResponseEntity<String> response =
732 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
734 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
735 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
736 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
740 public void deactivatePort() throws IOException {
741 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
742 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
743 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
745 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
746 RequestReferences requestReferences = new RequestReferences();
747 requestReferences.setInstanceId("1882939");
748 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
749 expectedResponse.setRequestReferences(requestReferences);
750 uri = servInstanceuri + "v7"
751 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
752 ResponseEntity<String> response =
753 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
755 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
756 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
757 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
761 public void addRelationships() throws IOException {
762 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
763 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
764 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
766 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
767 RequestReferences requestReferences = new RequestReferences();
768 requestReferences.setInstanceId("1882939");
769 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
770 expectedResponse.setRequestReferences(requestReferences);
771 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
772 ResponseEntity<String> response =
773 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
775 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
776 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
777 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
781 public void removeRelationships() throws IOException {
782 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
783 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
784 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
786 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
787 RequestReferences requestReferences = new RequestReferences();
788 requestReferences.setInstanceId("1882939");
789 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
790 expectedResponse.setRequestReferences(requestReferences);
791 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
792 ResponseEntity<String> response =
793 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
795 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
796 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
797 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
801 public void createVnfInstanceNoALaCarte() throws IOException {
802 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
803 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
804 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
807 wireMockServer.stubFor(get(urlMatching(
808 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
809 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
810 .withBody(getWiremockResponseForCatalogdb(
811 "vnfResourceCustomization_ReplaceVnf_Response.json"))
812 .withStatus(org.apache.http.HttpStatus.SC_OK)));
814 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
815 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
816 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
817 .withStatus(org.apache.http.HttpStatus.SC_OK)));
819 wireMockServer.stubFor(get(urlMatching(
820 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
821 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
822 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
823 .withStatus(org.apache.http.HttpStatus.SC_OK)));
826 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
827 RequestReferences requestReferences = new RequestReferences();
828 requestReferences.setInstanceId("1882939");
829 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
830 expectedResponse.setRequestReferences(requestReferences);
831 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
832 ResponseEntity<String> response =
833 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
835 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
836 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
837 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
841 public void createVnfInstance() throws IOException {
842 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
843 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
844 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
846 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
847 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
848 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
849 .withStatus(org.apache.http.HttpStatus.SC_OK)));
850 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
851 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
852 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
853 .withStatus(org.apache.http.HttpStatus.SC_OK)));
856 wireMockServer.stubFor(
857 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
858 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
859 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
860 .withStatus(org.apache.http.HttpStatus.SC_OK)));
862 wireMockServer.stubFor(get(urlMatching(
863 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
864 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
865 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
866 .withStatus(org.apache.http.HttpStatus.SC_OK)));
869 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
870 RequestReferences requestReferences = new RequestReferences();
871 requestReferences.setInstanceId("1882939");
872 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
873 expectedResponse.setRequestReferences(requestReferences);
874 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
875 ResponseEntity<String> response =
876 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
878 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
879 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
880 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
881 assertTrue(response.getBody().contains("1882939"));
885 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
886 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
887 ResponseEntity<String> response =
888 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
890 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
894 public void createVnfInstanceInvalidVnfResource() throws IOException {
895 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
896 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
898 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
899 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
900 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
904 public void replaceVnfInstance() throws IOException {
905 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
906 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
907 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
909 wireMockServer.stubFor(get(urlMatching(
910 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
911 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
912 .withBody(getWiremockResponseForCatalogdb(
913 "vnfResourceCustomization_ReplaceVnf_Response.json"))
914 .withStatus(org.apache.http.HttpStatus.SC_OK)));
916 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
917 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
918 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
919 .withStatus(org.apache.http.HttpStatus.SC_OK)));
921 wireMockServer.stubFor(get(urlMatching(
922 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
923 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
924 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
925 .withStatus(org.apache.http.HttpStatus.SC_OK)));
927 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
928 RequestReferences requestReferences = new RequestReferences();
929 requestReferences.setInstanceId("1882939");
930 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
931 expectedResponse.setRequestReferences(requestReferences);
932 uri = servInstanceuri + "v7"
933 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
934 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
936 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
937 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
938 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
942 public void replaceVnfRecreateInstance() throws IOException {
943 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
944 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
945 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
947 wireMockServer.stubFor(get(urlMatching(
948 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
949 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
950 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
951 .withStatus(org.apache.http.HttpStatus.SC_OK)));
953 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
954 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
955 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
956 .withStatus(org.apache.http.HttpStatus.SC_OK)));
958 wireMockServer.stubFor(get(urlMatching(
959 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
960 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
961 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
962 .withStatus(org.apache.http.HttpStatus.SC_OK)));
965 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
966 RequestReferences requestReferences = new RequestReferences();
967 requestReferences.setInstanceId("1882939");
968 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
969 expectedResponse.setRequestReferences(requestReferences);
970 uri = servInstanceuri + "v7"
971 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
972 ResponseEntity<String> response =
973 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
974 logger.debug(response.getBody());
976 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
977 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
978 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
982 public void recreateVnfInstance() throws IOException {
983 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
984 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
985 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
987 wireMockServer.stubFor(get(urlMatching(
988 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
989 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
990 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
991 .withStatus(org.apache.http.HttpStatus.SC_OK)));
993 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
994 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
995 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
996 .withStatus(org.apache.http.HttpStatus.SC_OK)));
998 wireMockServer.stubFor(get(urlMatching(
999 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1000 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1001 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1002 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1004 // expected response
1005 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1006 RequestReferences requestReferences = new RequestReferences();
1007 requestReferences.setInstanceId("1882939");
1008 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1009 expectedResponse.setRequestReferences(requestReferences);
1010 uri = servInstanceuri + "v7"
1011 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1012 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1013 logger.debug(response.getBody());
1015 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1016 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1017 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1021 public void updateVnfInstance() throws IOException {
1022 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1023 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1024 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1026 wireMockServer.stubFor(get(urlMatching(
1027 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1028 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1029 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1030 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1032 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1033 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1034 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1035 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1037 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1038 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1039 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1040 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1041 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1043 // expected response
1044 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1045 RequestReferences requestReferences = new RequestReferences();
1046 requestReferences.setInstanceId("1882939");
1047 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1048 expectedResponse.setRequestReferences(requestReferences);
1049 uri = servInstanceuri + "v7"
1050 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1051 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1053 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1054 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1055 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1059 public void applyUpdatedConfig() throws IOException {
1060 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1061 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1062 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1065 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1066 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1067 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1068 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1069 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1071 // expected response
1072 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1073 RequestReferences requestReferences = new RequestReferences();
1074 requestReferences.setInstanceId("1882939");
1075 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1076 expectedResponse.setRequestReferences(requestReferences);
1077 uri = servInstanceuri + "v7"
1078 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1079 ResponseEntity<String> response =
1080 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1082 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1083 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1084 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1088 public void deleteVnfInstanceV5() throws IOException {
1089 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1090 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1091 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1093 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1094 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1095 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1096 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1097 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1098 // expected response
1099 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1100 RequestReferences requestReferences = new RequestReferences();
1101 requestReferences.setInstanceId("1882939");
1102 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1103 expectedResponse.setRequestReferences(requestReferences);
1104 uri = servInstanceuri + "v5"
1105 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1106 ResponseEntity<String> response =
1107 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1109 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1110 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1111 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1115 public void createVfModuleInstance() throws IOException {
1116 wireMockServer.stubFor(get(urlMatching(
1117 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1118 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1119 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1120 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1122 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1123 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1124 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1125 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1127 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1128 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1129 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1130 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1132 wireMockServer.stubFor(get(urlMatching(
1133 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1134 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1135 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1136 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1138 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1139 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1140 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1142 wireMockServer.stubFor(get(urlMatching(
1143 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1144 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1145 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1146 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1147 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1148 // expected response
1149 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1150 RequestReferences requestReferences = new RequestReferences();
1151 requestReferences.setInstanceId("1882939");
1152 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1153 expectedResponse.setRequestReferences(requestReferences);
1154 uri = servInstanceuri + "v7"
1155 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1156 ResponseEntity<String> response =
1157 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1159 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1160 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1161 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1162 assertTrue(response.getBody().contains("1882939"));
1166 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1167 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1168 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1169 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1171 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1172 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1173 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1174 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1177 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1178 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1179 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1180 .withBody(getWiremockResponseForCatalogdb(
1181 "vnfResourceCustomizationForVfModule_Response.json"))
1182 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1184 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1185 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1186 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1187 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1189 wireMockServer.stubFor(get(urlMatching(
1190 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1191 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1192 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1193 .withBody(getWiremockResponseForCatalogdb(
1194 "vfModuleCustomizationPCM_Response.json"))
1195 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1197 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1198 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1199 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1200 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1202 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1204 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1205 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1208 wireMockServer.stubFor(
1209 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1210 + "[?]vnfComponentType=vfModule&action=createInstance"))
1211 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1212 .withBody(getWiremockResponseForCatalogdb(
1213 "vnfComponentRecipeVNF_API_Response.json"))
1214 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1216 // expected response
1217 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1218 RequestReferences requestReferences = new RequestReferences();
1219 requestReferences.setInstanceId("1882939");
1220 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1221 expectedResponse.setRequestReferences(requestReferences);
1222 uri = servInstanceuri + "v6"
1223 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1224 ResponseEntity<String> response =
1225 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1226 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1227 ObjectMapper mapper = new ObjectMapper();
1228 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1229 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1233 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1234 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1235 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1236 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1238 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1239 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1240 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1241 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1244 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1245 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1246 .withBody(getWiremockResponseForCatalogdb(
1247 "vnfResourceCustomizationForVfModule_Response.json"))
1248 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1250 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1251 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1252 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1253 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1255 wireMockServer.stubFor(get(urlMatching(
1256 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1257 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1258 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1259 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1261 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1262 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1263 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1264 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1266 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1267 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1268 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1269 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1271 wireMockServer.stubFor(get(urlMatching(
1272 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1273 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1274 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1275 .withBody(getWiremockResponseForCatalogdb(
1276 "vnfComponentRecipeDeleteVfModule_Response.json"))
1277 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1279 // expected response
1280 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1281 RequestReferences requestReferences = new RequestReferences();
1282 requestReferences.setInstanceId("1882939");
1283 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1284 expectedResponse.setRequestReferences(requestReferences);
1285 uri = servInstanceuri + "v6"
1286 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1287 ResponseEntity<String> response =
1288 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1291 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1292 ObjectMapper mapper = new ObjectMapper();
1293 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1294 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1298 public void createVfModuleInstanceNoRecipe() throws IOException {
1300 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1301 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1302 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1303 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1306 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1307 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1308 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1309 .withBody(getWiremockResponseForCatalogdb(
1310 "vnfResourceCustomizationForVfModule_Response.json"))
1311 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1313 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1314 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1315 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1316 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1318 wireMockServer.stubFor(
1319 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1320 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1321 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1322 .withBody(getWiremockResponseForCatalogdb(
1323 "vfModuleCustomizationPCM_Response.json"))
1324 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1326 uri = servInstanceuri + "v6"
1327 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1328 ResponseEntity<String> response =
1329 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1331 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1332 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1333 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1337 public void replaceVfModuleInstance() throws IOException {
1338 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1339 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1340 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1343 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1344 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1345 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1346 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1347 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1349 wireMockServer.stubFor(get(urlMatching(
1350 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1351 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1352 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1353 .withBody(getWiremockResponseForCatalogdb(
1354 "vnfComponentRecipeDeleteVfModule_Response.json"))
1355 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1356 // expected response
1357 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1358 RequestReferences requestReferences = new RequestReferences();
1359 requestReferences.setInstanceId("1882939");
1360 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1361 expectedResponse.setRequestReferences(requestReferences);
1362 uri = servInstanceuri + "v7"
1363 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1364 ResponseEntity<String> response =
1365 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1367 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1368 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1369 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1373 public void updateVfModuleInstance() throws IOException {
1374 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1375 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1376 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1378 wireMockServer.stubFor(get(urlMatching(
1379 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1380 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1381 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1382 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1384 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1385 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1386 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1387 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1389 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1390 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1391 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1392 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1394 wireMockServer.stubFor(get(urlMatching(
1395 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1396 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1397 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1398 .withBody(getWiremockResponseForCatalogdb(
1399 "vnfComponentRecipe_GRAPI_Response.json"))
1400 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1402 // expected response
1403 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1404 RequestReferences requestReferences = new RequestReferences();
1405 requestReferences.setInstanceId("1882939");
1406 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1407 expectedResponse.setRequestReferences(requestReferences);
1408 uri = servInstanceuri + "v7"
1409 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1410 ResponseEntity<String> response =
1411 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1412 logger.debug(response.getBody());
1414 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1415 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1416 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1420 public void createVfModuleNoModelType() throws IOException {
1421 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1422 expectedRecord.setRequestStatus("FAILED");
1423 expectedRecord.setAction("createInstance");
1424 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1425 expectedRecord.setProgress(100L);
1426 expectedRecord.setSource("VID");
1427 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1428 expectedRecord.setLastModifiedBy("APIH");
1429 expectedRecord.setVfModuleName("testVfModule2");
1430 expectedRecord.setVfModuleModelName("serviceModel");
1431 expectedRecord.setRequestScope("vfModule");
1432 expectedRecord.setRequestAction("createInstance");
1433 expectedRecord.setRequestorId("zz9999");
1434 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1435 // VnfType is not sent in this request, should be blank in db
1436 expectedRecord.setVnfType("");
1437 uri = servInstanceuri
1438 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1440 ResponseEntity<String> response =
1441 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1443 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1447 public void inPlaceSoftwareUpdate() throws IOException {
1448 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1449 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1450 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1452 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1453 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1454 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1455 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1456 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1458 // expected response
1459 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1460 RequestReferences requestReferences = new RequestReferences();
1461 requestReferences.setInstanceId("1882939");
1462 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1463 expectedResponse.setRequestReferences(requestReferences);
1464 uri = servInstanceuri + "v7"
1465 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1466 ResponseEntity<String> response =
1467 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1469 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1470 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1471 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1475 public void deleteVfModuleInstance() throws IOException {
1476 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1477 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1478 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1481 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1482 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1483 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1484 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1485 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1487 wireMockServer.stubFor(get(urlMatching(
1488 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1489 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1490 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1491 .withBody(getWiremockResponseForCatalogdb(
1492 "vnfComponentRecipeDeleteVfModule_Response.json"))
1493 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1495 // expected response
1496 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1497 RequestReferences requestReferences = new RequestReferences();
1498 requestReferences.setInstanceId("1882939");
1499 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1500 expectedResponse.setRequestReferences(requestReferences);
1501 uri = servInstanceuri + "v7"
1502 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1503 ResponseEntity<String> response =
1504 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1506 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1507 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1508 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1512 public void deleteVfModuleNoModelInvariantId() throws IOException {
1513 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1514 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1515 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1517 wireMockServer.stubFor(get(urlMatching(
1518 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1519 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1520 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1521 .withBody(getWiremockResponseForCatalogdb(
1522 "vnfComponentRecipeDeleteVfModule_Response.json"))
1523 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1525 // expected response
1526 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1527 RequestReferences requestReferences = new RequestReferences();
1528 requestReferences.setInstanceId("1882939");
1529 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1530 expectedResponse.setRequestReferences(requestReferences);
1531 uri = servInstanceuri + "v7"
1532 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1533 ResponseEntity<String> response =
1534 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1536 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1537 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1538 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1542 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1543 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1544 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1545 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1548 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1549 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1551 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1552 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1554 wireMockServer.stubFor(get(urlMatching(
1555 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1556 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1557 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1558 .withBody(getWiremockResponseForCatalogdb(
1559 "vnfComponentRecipeDeactivate_Response.json"))
1560 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1562 // expected response
1563 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1564 RequestReferences requestReferences = new RequestReferences();
1565 requestReferences.setInstanceId("1882939");
1566 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1567 expectedResponse.setRequestReferences(requestReferences);
1568 uri = servInstanceuri + "v7"
1569 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1570 ResponseEntity<String> response =
1571 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1573 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1574 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1575 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1579 public void createVolumeGroupInstance() throws IOException {
1580 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1581 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1582 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1584 wireMockServer.stubFor(get(urlMatching(
1585 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1586 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1587 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1588 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1590 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1591 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1592 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1593 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1595 wireMockServer.stubFor(get(urlMatching(
1596 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1597 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1598 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1599 .withBody(getWiremockResponseForCatalogdb(
1600 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1601 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1603 // expected response
1604 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1605 RequestReferences requestReferences = new RequestReferences();
1606 requestReferences.setInstanceId("1882939");
1607 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1608 expectedResponse.setRequestReferences(requestReferences);
1609 uri = servInstanceuri + "v7"
1610 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1611 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1613 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1614 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1615 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1616 assertTrue(response.getBody().contains("1882939"));
1620 public void updateVolumeGroupInstance() throws IOException {
1621 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1622 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1623 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1625 wireMockServer.stubFor(get(urlMatching(
1626 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1627 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1628 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1629 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1631 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1632 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1633 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1634 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1636 wireMockServer.stubFor(get(urlMatching(
1637 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1638 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1639 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1640 .withBody(getWiremockResponseForCatalogdb(
1641 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1642 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1644 // expected response
1645 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1646 RequestReferences requestReferences = new RequestReferences();
1647 requestReferences.setInstanceId("1882939");
1648 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1649 expectedResponse.setRequestReferences(requestReferences);
1650 uri = servInstanceuri + "v7"
1651 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1652 ResponseEntity<String> response =
1653 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1655 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1656 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1657 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1661 public void deleteVolumeGroupInstance() throws IOException {
1662 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1663 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1664 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1666 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1667 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1668 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1670 wireMockServer.stubFor(get(urlMatching(
1671 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1672 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1673 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1674 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1676 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1677 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1678 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1679 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1681 wireMockServer.stubFor(get(urlMatching(
1682 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1683 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1684 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1685 .withBody(getWiremockResponseForCatalogdb(
1686 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1687 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1689 // expected response
1690 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1691 RequestReferences requestReferences = new RequestReferences();
1692 requestReferences.setInstanceId("1882939");
1693 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1694 expectedResponse.setRequestReferences(requestReferences);
1695 uri = servInstanceuri + "v7"
1696 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1697 ResponseEntity<String> response =
1698 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1700 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1701 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1702 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1706 public void createNetworkInstance() throws IOException {
1707 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1708 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1709 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1711 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1712 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1713 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1714 .withStatus(HttpStatus.SC_OK)));
1716 wireMockServer.stubFor(
1717 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1718 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1719 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1720 .withStatus(HttpStatus.SC_OK)));
1722 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1723 + "modelName=GR-API-DEFAULT&action=createInstance"))
1724 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1725 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1726 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1728 // expected response
1729 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1730 RequestReferences requestReferences = new RequestReferences();
1731 requestReferences.setInstanceId("1882939");
1732 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1733 expectedResponse.setRequestReferences(requestReferences);
1734 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1735 ResponseEntity<String> response =
1736 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1738 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1739 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1740 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1744 public void updateNetworkInstance() throws IOException {
1745 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1746 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1747 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1749 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1750 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1751 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1752 .withStatus(HttpStatus.SC_OK)));
1754 wireMockServer.stubFor(
1755 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1756 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1757 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1758 .withStatus(HttpStatus.SC_OK)));
1760 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1761 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1762 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1763 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1764 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1765 // expected response
1766 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1767 RequestReferences requestReferences = new RequestReferences();
1768 requestReferences.setInstanceId("1882939");
1769 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1770 expectedResponse.setRequestReferences(requestReferences);
1771 uri = servInstanceuri + "v7"
1772 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1773 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1775 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1776 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1777 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1778 assertTrue(response.getBody().contains("1882939"));
1782 public void deleteNetworkInstance() throws IOException {
1783 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1784 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1785 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1787 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1788 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1789 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1790 .withStatus(HttpStatus.SC_OK)));
1792 wireMockServer.stubFor(
1793 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1794 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1795 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1796 .withStatus(HttpStatus.SC_OK)));
1798 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1799 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1800 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1801 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1802 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1804 // expected response
1805 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1806 RequestReferences requestReferences = new RequestReferences();
1807 requestReferences.setInstanceId("1882939");
1808 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1809 expectedResponse.setRequestReferences(requestReferences);
1810 uri = servInstanceuri + "v7"
1811 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1812 ResponseEntity<String> response =
1813 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1815 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1816 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1817 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1821 public void deleteNetworkInstanceNoReqParams() throws IOException {
1822 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1823 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1824 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1826 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1827 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1828 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1829 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1830 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1833 // expected response
1834 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1835 RequestReferences requestReferences = new RequestReferences();
1836 requestReferences.setInstanceId("1882939");
1837 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1838 expectedResponse.setRequestReferences(requestReferences);
1839 uri = servInstanceuri + "v6"
1840 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1841 ResponseEntity<String> response =
1842 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1844 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1845 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1846 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1850 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1852 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1853 expectedRecord.setRequestStatus("FAILED");
1854 expectedRecord.setStatusMessage("Error mapping request: ");
1855 expectedRecord.setProgress(100L);
1856 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1857 expectedRecord.setLastModifiedBy("APIH");
1858 expectedRecord.setRequestScope("network");
1859 expectedRecord.setRequestAction("deleteInstance");
1860 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1862 uri = servInstanceuri + "v6"
1863 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1864 ResponseEntity<String> response =
1865 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1869 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1873 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1874 uri = servInstanceuri + "v5"
1875 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1876 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1878 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1882 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1883 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1884 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1885 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1887 ServiceRecipe serviceRecipe = new ServiceRecipe();
1888 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1889 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1890 serviceRecipe.setAction(Action.createInstance.toString());
1891 serviceRecipe.setId(1);
1892 serviceRecipe.setRecipeTimeout(180);
1893 Service defaultService = new Service();
1894 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1896 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1897 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1898 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1900 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1901 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1902 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1904 uri = servInstanceuri + "v7" + "/serviceInstances";
1905 ResponseEntity<String> response =
1906 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1908 // expected response
1909 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1910 RequestReferences requestReferences = new RequestReferences();
1911 requestReferences.setInstanceId("1882939");
1912 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1913 expectedResponse.setRequestReferences(requestReferences);
1915 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1916 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1917 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1921 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1922 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1923 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1924 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1926 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1927 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1928 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1929 .withStatus(HttpStatus.SC_OK)));
1931 wireMockServer.stubFor(
1932 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1933 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1934 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1935 .withStatus(HttpStatus.SC_OK)));
1937 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1938 + "modelName=GR-API-DEFAULT&action=createInstance"))
1939 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1940 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1941 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1943 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1944 ResponseEntity<String> response =
1945 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1947 // expected response
1948 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1949 RequestReferences requestReferences = new RequestReferences();
1950 requestReferences.setInstanceId("1882939");
1951 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1952 expectedResponse.setRequestReferences(requestReferences);
1954 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1955 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1956 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1960 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1961 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1962 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1963 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1965 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1966 ResponseEntity<String> response =
1967 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1969 // expected response
1970 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1971 RequestReferences requestReferences = new RequestReferences();
1972 requestReferences.setInstanceId("1882939");
1973 expectedResponse.setRequestReferences(requestReferences);
1975 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1979 public void createNetworkInstanceTestApiGrApi() throws IOException {
1980 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1981 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1982 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1984 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1985 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1986 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1987 .withStatus(HttpStatus.SC_OK)));
1989 wireMockServer.stubFor(
1990 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1991 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1992 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1993 .withStatus(HttpStatus.SC_OK)));
1995 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1996 + "modelName=GR-API-DEFAULT&action=createInstance"))
1997 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1998 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1999 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2001 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2002 ResponseEntity<String> response =
2003 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2005 // expected response
2006 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2007 RequestReferences requestReferences = new RequestReferences();
2008 requestReferences.setInstanceId("1882939");
2009 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2010 expectedResponse.setRequestReferences(requestReferences);
2012 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2013 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2014 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2018 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2019 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2020 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2021 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2023 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2024 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2025 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2026 .withStatus(HttpStatus.SC_OK)));
2028 wireMockServer.stubFor(
2029 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2030 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2031 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2032 .withStatus(HttpStatus.SC_OK)));
2034 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2035 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2036 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2037 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2038 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2040 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2041 ResponseEntity<String> response =
2042 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2044 // expected response
2045 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2046 RequestReferences requestReferences = new RequestReferences();
2047 requestReferences.setInstanceId("1882939");
2048 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2049 expectedResponse.setRequestReferences(requestReferences);
2051 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2052 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2053 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2057 public void activateServiceInstanceRequestStatus() throws IOException {
2058 ServiceRecipe serviceRecipe = new ServiceRecipe();
2059 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2060 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2061 serviceRecipe.setAction(Action.createInstance.toString());
2062 serviceRecipe.setId(1);
2063 serviceRecipe.setRecipeTimeout(180);
2064 Service defaultService = new Service();
2065 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2067 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2068 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2069 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2071 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2072 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2073 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2075 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2076 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2077 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2080 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2081 RequestReferences requestReferences = new RequestReferences();
2082 requestReferences.setInstanceId("1882939");
2083 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2084 expectedResponse.setRequestReferences(requestReferences);
2085 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2086 ResponseEntity<String> response =
2087 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2089 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2090 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2091 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2095 public void invalidRequestId() throws IOException {
2096 String illegalRequestId = "1234";
2097 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2098 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2099 uri = servInstanceuri + "v5/serviceInstances";
2100 ResponseEntity<String> response =
2101 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2103 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2104 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2108 public void invalidBPELResponse() throws IOException {
2110 ServiceRecipe serviceRecipe = new ServiceRecipe();
2111 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2112 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2113 serviceRecipe.setAction(Action.createInstance.toString());
2114 serviceRecipe.setId(1);
2115 serviceRecipe.setRecipeTimeout(180);
2116 Service defaultService = new Service();
2117 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2119 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2120 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2121 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2123 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2124 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2125 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2127 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2128 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2129 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2131 uri = servInstanceuri + "v5/serviceInstances";
2132 ResponseEntity<String> response =
2133 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2135 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2136 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2137 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2138 realResponse.getServiceException().getText());
2142 public void unauthorizedBPELResponse() throws IOException {
2144 ServiceRecipe serviceRecipe = new ServiceRecipe();
2145 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2146 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2147 serviceRecipe.setAction(Action.createInstance.toString());
2148 serviceRecipe.setId(1);
2149 serviceRecipe.setRecipeTimeout(180);
2150 Service defaultService = new Service();
2151 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2153 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2154 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2155 .withBodyFile("Camunda/UnauthorizedResponse.json")
2156 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2158 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2159 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2160 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2162 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2163 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2164 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2166 uri = servInstanceuri + "v5/serviceInstances";
2167 ResponseEntity<String> response =
2168 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2170 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2171 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2172 assertEquals("Exception caught mapping Camunda JSON response to object",
2173 realResponse.getServiceException().getText());
2177 public void invalidBPELResponse2() throws IOException {
2179 ServiceRecipe serviceRecipe = new ServiceRecipe();
2180 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2181 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2182 serviceRecipe.setAction(Action.createInstance.toString());
2183 serviceRecipe.setId(1);
2184 serviceRecipe.setRecipeTimeout(180);
2185 Service defaultService = new Service();
2186 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2188 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2189 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2190 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2192 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2193 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2194 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2196 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2197 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2198 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2199 uri = servInstanceuri + "v5/serviceInstances";
2200 ResponseEntity<String> response =
2201 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2203 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2204 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2205 assertTrue(realResponse.getServiceException().getText()
2206 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2210 public void createMacroServiceInstance() throws IOException {
2211 ServiceRecipe serviceRecipe = new ServiceRecipe();
2212 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2213 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2214 serviceRecipe.setAction(Action.createInstance.toString());
2215 serviceRecipe.setId(1);
2216 serviceRecipe.setRecipeTimeout(180);
2217 Service defaultService = new Service();
2218 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2220 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2221 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2222 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2224 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2225 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2226 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2228 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2229 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2230 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2232 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2233 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2234 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2237 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2238 RequestReferences requestReferences = new RequestReferences();
2239 requestReferences.setInstanceId("1882939");
2240 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2241 expectedResponse.setRequestReferences(requestReferences);
2242 uri = servInstanceUriPrev7 + "v5";
2243 ResponseEntity<String> response =
2244 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2247 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2248 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2249 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2253 public void testUserParams() throws IOException {
2254 ObjectMapper mapper = new ObjectMapper();
2255 ServiceInstancesRequest request =
2256 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2257 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2258 String userParamsTxt = inputStream("/userParams.txt");
2260 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2261 System.out.println(userParams);
2262 assertTrue(userParams.size() > 0);
2263 assertTrue(userParams.get(0).containsKey("name"));
2264 assertTrue(userParams.get(0).containsKey("value"));
2265 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2269 public void testConfigureCloudConfig() throws IOException {
2270 ObjectMapper mapper = new ObjectMapper();
2271 ServiceInstancesRequest request =
2272 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2273 CloudConfiguration cloudConfig =
2274 servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2276 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2277 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2281 public void testMapToLegacyRequest() throws IOException {
2282 ObjectMapper mapper = new ObjectMapper();
2283 ServiceInstancesRequest request =
2284 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2285 ServiceInstancesRequest expected =
2286 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2287 servInstances.mapToLegacyRequest(request.getRequestDetails());
2288 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2289 assertThat(request, sameBeanAs(expected));
2293 public void scaleOutVfModule() throws IOException {
2294 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2295 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2296 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2298 wireMockServer.stubFor(get(urlMatching(
2299 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2300 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2301 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2302 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2304 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2305 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2306 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2307 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2309 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2310 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2311 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2312 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2315 wireMockServer.stubFor(get(urlMatching(
2316 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2317 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2318 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2319 .withBody(getWiremockResponseForCatalogdb(
2320 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2321 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2323 wireMockServer.stubFor(get(urlMatching(
2324 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2325 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2326 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2327 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2329 // expected response
2330 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2331 RequestReferences requestReferences = new RequestReferences();
2332 requestReferences.setInstanceId("1882939");
2333 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2334 expectedResponse.setRequestReferences(requestReferences);
2335 uri = servInstanceuri + "v7"
2336 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2337 ResponseEntity<String> response =
2338 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2340 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2341 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2342 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2343 assertTrue(response.getBody().contains("1882939"));
2347 public void createServiceInstanceBadResponse() throws IOException {
2348 ServiceRecipe serviceRecipe = new ServiceRecipe();
2349 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2350 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2351 serviceRecipe.setAction(Action.createInstance.toString());
2352 serviceRecipe.setId(1);
2353 serviceRecipe.setRecipeTimeout(180);
2354 Service defaultService = new Service();
2355 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2357 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2358 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2359 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2361 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2362 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2363 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2365 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2366 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2367 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2369 uri = servInstanceuri + "v5/serviceInstances";
2370 ResponseEntity<String> response =
2371 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2373 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2374 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2375 assertEquals("Exception caught mapping Camunda JSON response to object",
2376 realResponse.getServiceException().getText());
2380 public void createServiceInstanceDuplicateError() throws IOException {
2381 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2382 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2383 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2385 uri = servInstanceuri + "v5/serviceInstances";
2386 ResponseEntity<String> response =
2387 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2389 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2390 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2392 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2393 realResponse.getServiceException().getText());
2397 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2398 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2400 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2401 .withStatus(HttpStatus.SC_ACCEPTED)));
2402 wireMockServer.stubFor(get(
2403 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2404 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2405 .withBodyFile("Camunda/HistoryCheckResponse.json")
2406 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2408 uri = servInstanceuri + "v5/serviceInstances";
2409 ResponseEntity<String> response =
2410 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2412 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2413 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2415 "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.",
2416 realResponse.getServiceException().getText());
2420 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2421 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2422 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2423 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2424 .withStatus(HttpStatus.SC_ACCEPTED)));
2425 wireMockServer.stubFor(get(
2426 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2427 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2428 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2430 uri = servInstanceuri + "v5/serviceInstances";
2431 ResponseEntity<String> response =
2432 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2434 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2435 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2437 "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2438 realResponse.getServiceException().getText());
2442 public void createServiceInstanceDuplicate() throws IOException {
2443 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2445 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2447 uri = servInstanceuri + "v5/serviceInstances";
2448 ResponseEntity<String> response =
2449 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2451 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2452 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2454 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2455 realResponse.getServiceException().getText());
2459 public void createServiceInstanceSaveError() throws IOException {
2460 ServiceRecipe serviceRecipe = new ServiceRecipe();
2461 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2462 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2463 serviceRecipe.setAction(Action.createInstance.toString());
2464 serviceRecipe.setId(1);
2465 serviceRecipe.setRecipeTimeout(180);
2466 Service defaultService = new Service();
2467 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2468 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2469 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2470 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2471 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2472 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2473 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2475 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2476 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2477 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2479 uri = servInstanceuri + "v5/serviceInstances";
2480 ResponseEntity<String> response =
2481 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2483 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2484 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2486 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2487 realResponse.getServiceException().getText());
2491 public void createPortConfigurationSaveError() throws IOException {
2492 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2493 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2494 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2495 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2496 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2497 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2499 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2500 ResponseEntity<String> response =
2501 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2503 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2504 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2506 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2507 realResponse.getServiceException().getText());
2511 public void createPortConfigDbUpdateError() throws IOException {
2512 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2513 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2514 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2516 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2517 ResponseEntity<String> response =
2518 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2520 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2521 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2523 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2524 realResponse.getServiceException().getText());
2528 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2529 TestAppender.events.clear();
2530 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2531 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2532 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2534 wireMockServer.stubFor(get(urlMatching(
2535 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2536 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2537 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2538 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2540 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2541 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2542 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2543 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2545 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2546 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2547 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2548 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2549 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2550 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2552 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2553 RequestReferences requestReferences = new RequestReferences();
2554 requestReferences.setInstanceId("1882939");
2555 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2556 expectedResponse.setRequestReferences(requestReferences);
2557 uri = servInstanceuri
2558 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2559 ResponseEntity<String> response =
2560 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2562 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2563 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2564 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2565 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2567 for (ILoggingEvent logEvent : TestAppender.events) {
2568 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging")
2569 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
2570 Map<String, String> mdc = logEvent.getMDCPropertyMap();
2571 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2572 assertEquals("VID", mdc.get(PARTNERNAME));
2578 public void createInstanceGroup() throws IOException {
2579 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2580 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2581 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2584 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2585 RequestReferences requestReferences = new RequestReferences();
2586 requestReferences.setInstanceId("1882939");
2587 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2588 expectedResponse.setRequestReferences(requestReferences);
2589 uri = servInstanceuri + "/v7/instanceGroups";
2590 ResponseEntity<String> response =
2591 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2594 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2595 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2596 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2600 public void deleteInstanceGroup() throws IOException {
2601 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2602 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2603 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2606 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2607 RequestReferences requestReferences = new RequestReferences();
2608 requestReferences.setInstanceId("1882939");
2609 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2610 expectedResponse.setRequestReferences(requestReferences);
2611 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2612 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2615 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2616 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2617 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2621 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2622 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2623 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2625 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2626 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2627 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2631 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2632 HttpHeaders noPartnerHeaders = new HttpHeaders();
2633 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2634 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2635 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2636 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2638 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2639 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2640 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2644 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2645 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2646 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2647 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2649 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2650 RequestReferences requestReferences = new RequestReferences();
2651 requestReferences.setInstanceId("1882939");
2652 expectedResponse.setRequestReferences(requestReferences);
2653 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2654 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2657 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2658 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2659 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2663 public void addMembers() throws IOException {
2664 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2665 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2666 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2668 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2669 RequestReferences requestReferences = new RequestReferences();
2670 requestReferences.setInstanceId("1882939");
2671 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2672 expectedResponse.setRequestReferences(requestReferences);
2673 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2674 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2677 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2678 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2679 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2683 public void removeMembers() throws IOException {
2684 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2685 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2686 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2688 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2689 RequestReferences requestReferences = new RequestReferences();
2690 requestReferences.setInstanceId("1882939");
2691 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2692 expectedResponse.setRequestReferences(requestReferences);
2693 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2694 ResponseEntity<String> response =
2695 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2698 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2699 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2700 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2704 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2705 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2706 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2707 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2709 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2710 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2711 .withStatus(HttpStatus.SC_NOT_FOUND)));
2713 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2714 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2715 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2716 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2717 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2719 // expected response
2720 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2721 RequestReferences requestReferences = new RequestReferences();
2722 requestReferences.setInstanceId("1882939");
2723 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2724 expectedResponse.setRequestReferences(requestReferences);
2725 uri = servInstanceuri + "v7"
2726 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2727 ResponseEntity<String> response =
2728 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2730 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2731 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2732 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2736 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2737 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2738 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2739 .withStatus(HttpStatus.SC_NOT_FOUND)));
2741 uri = servInstanceuri + "v7"
2742 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2743 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2745 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2746 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2747 assertEquals(realResponse.getServiceException().getText(),
2748 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");