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.onap.logging.ref.slf4j.ONAPLogConstants;
59 import org.onap.so.db.catalog.beans.Service;
60 import org.onap.so.db.catalog.beans.ServiceRecipe;
61 import org.onap.so.db.request.beans.InfraActiveRequests;
62 import org.onap.so.logger.HttpHeadersConstants;
63 import org.onap.so.serviceinstancebeans.CloudConfiguration;
64 import org.onap.so.serviceinstancebeans.RequestError;
65 import org.onap.so.serviceinstancebeans.RequestParameters;
66 import org.onap.so.serviceinstancebeans.RequestReferences;
67 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
68 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
69 import org.springframework.beans.factory.annotation.Autowired;
70 import org.springframework.beans.factory.annotation.Value;
71 import org.springframework.http.HttpEntity;
72 import org.springframework.http.HttpHeaders;
73 import org.springframework.http.HttpMethod;
74 import org.springframework.http.ResponseEntity;
75 import org.springframework.util.ResourceUtils;
76 import org.springframework.web.util.UriComponentsBuilder;
77 import com.fasterxml.jackson.annotation.JsonInclude.Include;
78 import com.fasterxml.jackson.core.JsonParseException;
79 import com.fasterxml.jackson.core.JsonProcessingException;
80 import com.fasterxml.jackson.databind.DeserializationFeature;
81 import com.fasterxml.jackson.databind.JsonMappingException;
82 import com.fasterxml.jackson.databind.ObjectMapper;
83 import com.github.tomakehurst.wiremock.http.Fault;
84 import ch.qos.logback.classic.spi.ILoggingEvent;
87 public class ServiceInstancesTest extends BaseTest {
89 private final ObjectMapper mapper = new ObjectMapper();
90 private ObjectMapper errorMapper = new ObjectMapper();
93 private ServiceInstances servInstances;
95 @Value("${wiremock.server.port}")
96 private String wiremockPort;
98 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
99 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
101 private URL selfLink;
102 private URL initialUrl;
103 private int initialPort;
104 private HttpHeaders headers;
107 public void beforeClass() {
108 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
109 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
110 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
112 headers = new HttpHeaders();
113 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
114 headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
115 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
116 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
117 headers.set(CLIENT_ID, "VID");
118 headers.set(REQUESTOR_ID, "xxxxxx");
119 try { // generate one-time port number to avoid RANDOM port number later.
120 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
121 initialPort = initialUrl.getPort();
122 } catch (MalformedURLException e) {
125 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*")).willReturn(aResponse()
126 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
129 public String inputStream(String JsonInput) throws IOException {
130 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
131 return new String(Files.readAllBytes(Paths.get(JsonInput)));
134 private URL createExpectedSelfLink(String version, String requestId) {
135 System.out.println("createdUrl: " + initialUrl.toString());
137 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
138 } catch (MalformedURLException e) {
144 private String getWiremockResponseForCatalogdb(String file) {
146 File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
147 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
148 "localhost:" + wiremockPort);
149 } catch (IOException e) {
156 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
157 HttpHeaders headers) {
159 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
160 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
162 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
163 headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
166 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
168 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
170 return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
173 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
174 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
178 public void createServiceInstanceVIDDefault() throws IOException {
179 TestAppender.events.clear();
181 ServiceRecipe serviceRecipe = new ServiceRecipe();
182 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
183 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
184 serviceRecipe.setAction(Action.createInstance.toString());
185 serviceRecipe.setId(1);
186 serviceRecipe.setRecipeTimeout(180);
187 Service defaultService = new Service();
188 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
191 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
192 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
193 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
195 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
196 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
197 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
199 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
200 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
201 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
204 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
205 RequestReferences requestReferences = new RequestReferences();
206 requestReferences.setInstanceId("1882939");
207 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
208 expectedResponse.setRequestReferences(requestReferences);
209 uri = servInstanceuri + "v5/serviceInstances";
210 ResponseEntity<String> response =
211 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
214 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
215 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
216 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
220 for (ILoggingEvent logEvent : TestAppender.events)
221 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
222 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
223 Map<String, String> mdc = logEvent.getMDCPropertyMap();
224 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
225 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
226 assertNotNull(mdc.get(INVOCATION_ID));
227 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
228 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
229 assertEquals("INPROGRESS", mdc.get(STATUSCODE));
230 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
231 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
232 Map<String, String> mdc = logEvent.getMDCPropertyMap();
233 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
234 assertNotNull(mdc.get(ENDTIME));
235 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
236 assertNotNull(mdc.get(INVOCATION_ID));
237 assertEquals("202", mdc.get(RESPONSECODE));
238 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
239 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
240 assertEquals("COMPLETE", mdc.get(STATUSCODE));
241 assertNotNull(mdc.get(RESPONSEDESC));
242 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
243 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
244 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
249 public void createServiceInstanceServiceInstancesUri() throws IOException {
250 ServiceRecipe serviceRecipe = new ServiceRecipe();
251 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
252 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
253 serviceRecipe.setAction(Action.createInstance.toString());
254 serviceRecipe.setId(1);
255 serviceRecipe.setRecipeTimeout(180);
256 Service defaultService = new Service();
257 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
259 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
260 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
261 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
264 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
265 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
266 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
268 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
269 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
270 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
272 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
273 RequestReferences requestReferences = new RequestReferences();
274 requestReferences.setInstanceId("1882939");
275 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
276 expectedResponse.setRequestReferences(requestReferences);
277 uri = servInstanceUriPrev7 + "v5";
278 ResponseEntity<String> response =
279 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
282 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
283 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
284 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
288 public void createServiceInstanceBpelStatusError() throws IOException {
289 ServiceRecipe serviceRecipe = new ServiceRecipe();
290 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
291 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
292 serviceRecipe.setAction(Action.createInstance.toString());
293 serviceRecipe.setId(1);
294 serviceRecipe.setRecipeTimeout(180);
295 Service defaultService = new Service();
296 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
299 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
300 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
301 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
304 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
305 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
306 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
308 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
310 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
312 uri = servInstanceuri + "v5/serviceInstances";
313 ResponseEntity<String> response =
314 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
316 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
320 public void createServiceInstanceBadGateway() throws IOException {
321 ServiceRecipe serviceRecipe = new ServiceRecipe();
322 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
323 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
324 serviceRecipe.setAction(Action.createInstance.toString());
325 serviceRecipe.setId(1);
326 serviceRecipe.setRecipeTimeout(180);
327 Service defaultService = new Service();
328 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
330 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
331 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
333 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
335 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
337 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
339 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
341 uri = servInstanceuri + "v5/serviceInstances";
342 ResponseEntity<String> response =
343 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
345 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
349 public void createServiceInstanceEmptyResponse() throws IOException {
350 ServiceRecipe serviceRecipe = new ServiceRecipe();
351 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
352 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
353 serviceRecipe.setAction(Action.createInstance.toString());
354 serviceRecipe.setId(1);
355 serviceRecipe.setRecipeTimeout(180);
356 Service defaultService = new Service();
357 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
359 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
360 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
362 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
363 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
364 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
366 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
367 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
368 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
370 uri = servInstanceuri + "v5/serviceInstances";
371 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
373 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
377 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
378 TestAppender.events.clear();
379 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
380 HttpHeaders requestIDheaders = new HttpHeaders();
381 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
382 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
383 HttpMethod.POST, requestIDheaders);
385 Service defaultService = new Service();
386 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
388 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
389 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
390 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
393 wireMockServer.stubFor(get(urlMatching(
394 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
395 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
396 .withStatus(HttpStatus.SC_NOT_FOUND)));
398 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
402 public void activateServiceInstanceNoRecipe() throws IOException {
403 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
404 Service defaultService = new Service();
405 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
406 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
407 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
408 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
410 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
411 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
413 ResponseEntity<String> response =
414 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
416 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
420 public void activateServiceInstance() throws IOException {
421 ServiceRecipe serviceRecipe = new ServiceRecipe();
422 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
423 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
424 serviceRecipe.setAction(Action.createInstance.toString());
425 serviceRecipe.setId(1);
426 serviceRecipe.setRecipeTimeout(180);
427 Service defaultService = new Service();
428 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
430 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
431 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
432 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
434 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
435 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
436 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
438 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
439 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
440 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
442 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
443 RequestReferences requestReferences = new RequestReferences();
444 requestReferences.setInstanceId("1882939");
445 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
446 expectedResponse.setRequestReferences(requestReferences);
447 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
448 ResponseEntity<String> response =
449 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
451 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
452 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
453 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
457 public void deactivateServiceInstance() throws IOException {
459 ServiceRecipe serviceRecipe = new ServiceRecipe();
460 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
461 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
462 serviceRecipe.setAction(Action.createInstance.toString());
463 serviceRecipe.setId(1);
464 serviceRecipe.setRecipeTimeout(180);
465 Service defaultService = new Service();
466 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
468 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
469 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
470 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
472 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
473 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
474 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
476 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
477 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
478 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
480 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
481 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
482 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
485 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
486 RequestReferences requestReferences = new RequestReferences();
487 requestReferences.setInstanceId("1882939");
488 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
489 expectedResponse.setRequestReferences(requestReferences);
490 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
491 ResponseEntity<String> response =
492 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
494 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
495 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
496 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
500 public void deleteServiceInstance() throws IOException {
501 ServiceRecipe serviceRecipe = new ServiceRecipe();
502 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
503 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
504 serviceRecipe.setAction(Action.createInstance.toString());
505 serviceRecipe.setId(1);
506 serviceRecipe.setRecipeTimeout(180);
507 Service defaultService = new Service();
508 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
510 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
511 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
512 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
514 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
515 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
516 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
518 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
519 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
520 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
522 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
523 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
524 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
526 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
527 RequestReferences requestReferences = new RequestReferences();
528 requestReferences.setInstanceId("1882939");
529 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
530 expectedResponse.setRequestReferences(requestReferences);
531 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
532 ResponseEntity<String> response =
533 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
535 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
536 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
537 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
541 public void assignServiceInstance() throws IOException {
542 ServiceRecipe serviceRecipe = new ServiceRecipe();
543 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
544 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
545 serviceRecipe.setAction(Action.createInstance.toString());
546 serviceRecipe.setId(1);
547 serviceRecipe.setRecipeTimeout(180);
548 Service defaultService = new Service();
549 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
551 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
552 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
553 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
555 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
556 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
557 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
559 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
560 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
561 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
563 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
564 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
565 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
567 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
568 RequestReferences requestReferences = new RequestReferences();
569 requestReferences.setInstanceId("1882939");
570 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
571 expectedResponse.setRequestReferences(requestReferences);
572 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
573 ResponseEntity<String> response =
574 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
576 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
577 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
578 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
582 public void unassignServiceInstance() throws IOException {
583 ServiceRecipe serviceRecipe = new ServiceRecipe();
584 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
585 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
586 serviceRecipe.setAction(Action.createInstance.toString());
587 serviceRecipe.setId(1);
588 serviceRecipe.setRecipeTimeout(180);
589 Service defaultService = new Service();
590 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
592 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
593 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
594 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
596 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
597 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
598 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
600 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
601 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
602 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
604 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
605 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
606 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
608 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
609 RequestReferences requestReferences = new RequestReferences();
610 requestReferences.setInstanceId("1882939");
611 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
612 expectedResponse.setRequestReferences(requestReferences);
613 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
614 ResponseEntity<String> response =
615 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
617 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
618 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
619 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
623 public void createPortConfiguration() throws IOException {
624 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
625 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
626 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
628 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
629 RequestReferences requestReferences = new RequestReferences();
630 requestReferences.setInstanceId("1882939");
631 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
632 expectedResponse.setRequestReferences(requestReferences);
633 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
634 ResponseEntity<String> response =
635 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
637 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
638 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
639 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
640 assertTrue(response.getBody().contains("1882939"));
644 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
645 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
646 ResponseEntity<String> response =
647 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
649 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
653 public void deletePortConfiguration() throws IOException {
654 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
656 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
659 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
660 RequestReferences requestReferences = new RequestReferences();
661 requestReferences.setInstanceId("1882939");
662 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
663 expectedResponse.setRequestReferences(requestReferences);
664 uri = servInstanceuri + "v7"
665 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
666 ResponseEntity<String> response =
667 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
669 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
670 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
671 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
675 public void enablePort() throws IOException {
676 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
677 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
678 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
680 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
681 RequestReferences requestReferences = new RequestReferences();
682 requestReferences.setInstanceId("1882939");
683 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
684 expectedResponse.setRequestReferences(requestReferences);
685 uri = servInstanceuri + "v7"
686 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
687 ResponseEntity<String> response =
688 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
690 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
691 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
692 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
696 public void disablePort() throws IOException {
697 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
698 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
699 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
701 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
702 RequestReferences requestReferences = new RequestReferences();
703 requestReferences.setInstanceId("1882939");
704 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
705 expectedResponse.setRequestReferences(requestReferences);
706 uri = servInstanceuri + "v7"
707 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
708 ResponseEntity<String> response =
709 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
711 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
712 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
713 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
717 public void activatePort() throws IOException {
718 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
719 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
720 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
722 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
723 RequestReferences requestReferences = new RequestReferences();
724 requestReferences.setInstanceId("1882939");
725 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
726 expectedResponse.setRequestReferences(requestReferences);
727 uri = servInstanceuri + "v7"
728 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
729 ResponseEntity<String> response =
730 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
732 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
733 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
734 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
738 public void deactivatePort() throws IOException {
739 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
740 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
741 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
743 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
744 RequestReferences requestReferences = new RequestReferences();
745 requestReferences.setInstanceId("1882939");
746 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
747 expectedResponse.setRequestReferences(requestReferences);
748 uri = servInstanceuri + "v7"
749 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
750 ResponseEntity<String> response =
751 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
753 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
754 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
755 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
759 public void addRelationships() throws IOException {
760 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
761 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
762 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
764 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
765 RequestReferences requestReferences = new RequestReferences();
766 requestReferences.setInstanceId("1882939");
767 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
768 expectedResponse.setRequestReferences(requestReferences);
769 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
770 ResponseEntity<String> response =
771 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
773 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
774 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
775 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
779 public void removeRelationships() throws IOException {
780 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
781 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
782 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
784 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
785 RequestReferences requestReferences = new RequestReferences();
786 requestReferences.setInstanceId("1882939");
787 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
788 expectedResponse.setRequestReferences(requestReferences);
789 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
790 ResponseEntity<String> response =
791 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
793 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
794 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
795 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
799 public void createVnfInstanceNoALaCarte() throws IOException {
800 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
801 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
802 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
805 wireMockServer.stubFor(get(urlMatching(
806 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
807 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
808 .withBody(getWiremockResponseForCatalogdb(
809 "vnfResourceCustomization_ReplaceVnf_Response.json"))
810 .withStatus(org.apache.http.HttpStatus.SC_OK)));
812 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
813 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
814 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
815 .withStatus(org.apache.http.HttpStatus.SC_OK)));
817 wireMockServer.stubFor(get(urlMatching(
818 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
819 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
820 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
821 .withStatus(org.apache.http.HttpStatus.SC_OK)));
824 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
825 RequestReferences requestReferences = new RequestReferences();
826 requestReferences.setInstanceId("1882939");
827 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
828 expectedResponse.setRequestReferences(requestReferences);
829 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
830 ResponseEntity<String> response =
831 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
833 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
834 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
835 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
839 public void createVnfInstance() throws IOException {
840 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
841 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
842 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
844 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
846 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
847 .withStatus(org.apache.http.HttpStatus.SC_OK)));
848 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
849 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
850 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
851 .withStatus(org.apache.http.HttpStatus.SC_OK)));
854 wireMockServer.stubFor(
855 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
856 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
857 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
858 .withStatus(org.apache.http.HttpStatus.SC_OK)));
860 wireMockServer.stubFor(get(urlMatching(
861 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
862 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
863 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
864 .withStatus(org.apache.http.HttpStatus.SC_OK)));
867 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
868 RequestReferences requestReferences = new RequestReferences();
869 requestReferences.setInstanceId("1882939");
870 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
871 expectedResponse.setRequestReferences(requestReferences);
872 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
873 ResponseEntity<String> response =
874 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
876 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
877 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
878 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
879 assertTrue(response.getBody().contains("1882939"));
883 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
884 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
885 ResponseEntity<String> response =
886 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
888 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
892 public void createVnfInstanceInvalidVnfResource() throws IOException {
893 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
894 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
896 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
897 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
898 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
902 public void replaceVnfInstance() throws IOException {
903 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
904 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
905 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
907 wireMockServer.stubFor(get(urlMatching(
908 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
909 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
910 .withBody(getWiremockResponseForCatalogdb(
911 "vnfResourceCustomization_ReplaceVnf_Response.json"))
912 .withStatus(org.apache.http.HttpStatus.SC_OK)));
914 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
915 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
916 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
917 .withStatus(org.apache.http.HttpStatus.SC_OK)));
919 wireMockServer.stubFor(get(urlMatching(
920 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
921 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
922 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
923 .withStatus(org.apache.http.HttpStatus.SC_OK)));
925 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
926 RequestReferences requestReferences = new RequestReferences();
927 requestReferences.setInstanceId("1882939");
928 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
929 expectedResponse.setRequestReferences(requestReferences);
930 uri = servInstanceuri + "v7"
931 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
932 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
934 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
935 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
936 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
940 public void replaceVnfRecreateInstance() throws IOException {
941 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
942 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
943 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
945 wireMockServer.stubFor(get(urlMatching(
946 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
947 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
948 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
949 .withStatus(org.apache.http.HttpStatus.SC_OK)));
951 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
952 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
953 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
954 .withStatus(org.apache.http.HttpStatus.SC_OK)));
956 wireMockServer.stubFor(get(urlMatching(
957 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
958 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
959 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
960 .withStatus(org.apache.http.HttpStatus.SC_OK)));
963 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
964 RequestReferences requestReferences = new RequestReferences();
965 requestReferences.setInstanceId("1882939");
966 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
967 expectedResponse.setRequestReferences(requestReferences);
968 uri = servInstanceuri + "v7"
969 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
970 ResponseEntity<String> response =
971 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
972 logger.debug(response.getBody());
974 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
975 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
976 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
980 public void recreateVnfInstance() throws IOException {
981 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
982 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
983 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
985 wireMockServer.stubFor(get(urlMatching(
986 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
987 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
988 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
989 .withStatus(org.apache.http.HttpStatus.SC_OK)));
991 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
992 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
993 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
994 .withStatus(org.apache.http.HttpStatus.SC_OK)));
996 wireMockServer.stubFor(get(urlMatching(
997 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
998 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
999 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1000 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1002 // expected response
1003 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1004 RequestReferences requestReferences = new RequestReferences();
1005 requestReferences.setInstanceId("1882939");
1006 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1007 expectedResponse.setRequestReferences(requestReferences);
1008 uri = servInstanceuri + "v7"
1009 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1010 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1011 logger.debug(response.getBody());
1013 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1014 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1015 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1019 public void updateVnfInstance() throws IOException {
1020 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1021 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1022 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1024 wireMockServer.stubFor(get(urlMatching(
1025 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1026 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1027 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1028 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1030 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1031 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1032 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1033 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1035 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1036 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1037 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1038 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1039 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1041 // expected response
1042 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1043 RequestReferences requestReferences = new RequestReferences();
1044 requestReferences.setInstanceId("1882939");
1045 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1046 expectedResponse.setRequestReferences(requestReferences);
1047 uri = servInstanceuri + "v7"
1048 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1049 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1051 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1052 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1053 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1057 public void applyUpdatedConfig() throws IOException {
1058 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1059 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1060 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1063 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1064 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1065 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1066 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1067 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1069 // expected response
1070 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1071 RequestReferences requestReferences = new RequestReferences();
1072 requestReferences.setInstanceId("1882939");
1073 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1074 expectedResponse.setRequestReferences(requestReferences);
1075 uri = servInstanceuri + "v7"
1076 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1077 ResponseEntity<String> response =
1078 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1080 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1081 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1082 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1086 public void deleteVnfInstanceV5() throws IOException {
1087 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1088 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1089 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1091 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1092 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1093 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1094 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1095 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1096 // expected response
1097 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1098 RequestReferences requestReferences = new RequestReferences();
1099 requestReferences.setInstanceId("1882939");
1100 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1101 expectedResponse.setRequestReferences(requestReferences);
1102 uri = servInstanceuri + "v5"
1103 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1104 ResponseEntity<String> response =
1105 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1107 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1108 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1109 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1113 public void createVfModuleInstance() throws IOException {
1114 wireMockServer.stubFor(get(urlMatching(
1115 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1116 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1117 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1118 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1120 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1121 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1122 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1123 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1125 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1127 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1128 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1130 wireMockServer.stubFor(get(urlMatching(
1131 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1132 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1133 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1134 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1136 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1137 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1138 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1140 wireMockServer.stubFor(get(urlMatching(
1141 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1142 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1143 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1144 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1145 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1146 // expected response
1147 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1148 RequestReferences requestReferences = new RequestReferences();
1149 requestReferences.setInstanceId("1882939");
1150 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1151 expectedResponse.setRequestReferences(requestReferences);
1152 uri = servInstanceuri + "v7"
1153 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1154 ResponseEntity<String> response =
1155 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1157 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1158 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1159 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1160 assertTrue(response.getBody().contains("1882939"));
1164 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1165 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1166 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1167 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1169 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1170 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1171 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1172 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1175 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1176 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1177 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1178 .withBody(getWiremockResponseForCatalogdb(
1179 "vnfResourceCustomizationForVfModule_Response.json"))
1180 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1182 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1183 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1184 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1185 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1187 wireMockServer.stubFor(get(urlMatching(
1188 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1189 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1190 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1191 .withBody(getWiremockResponseForCatalogdb(
1192 "vfModuleCustomizationPCM_Response.json"))
1193 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1195 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1196 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1197 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1198 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1200 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1201 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1202 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1203 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1206 wireMockServer.stubFor(
1207 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1208 + "[?]vnfComponentType=vfModule&action=createInstance"))
1209 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1210 .withBody(getWiremockResponseForCatalogdb(
1211 "vnfComponentRecipeVNF_API_Response.json"))
1212 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1214 // expected response
1215 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1216 RequestReferences requestReferences = new RequestReferences();
1217 requestReferences.setInstanceId("1882939");
1218 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1219 expectedResponse.setRequestReferences(requestReferences);
1220 uri = servInstanceuri + "v6"
1221 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1222 ResponseEntity<String> response =
1223 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1224 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1225 ObjectMapper mapper = new ObjectMapper();
1226 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1227 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1231 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1232 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1233 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1234 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1236 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1237 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1238 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1239 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1242 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1244 .withBody(getWiremockResponseForCatalogdb(
1245 "vnfResourceCustomizationForVfModule_Response.json"))
1246 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1248 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1249 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1250 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1251 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1253 wireMockServer.stubFor(get(urlMatching(
1254 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1255 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1256 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1257 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1259 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1260 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1261 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1262 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1264 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1265 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1266 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1267 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1269 wireMockServer.stubFor(get(urlMatching(
1270 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1271 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1272 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1273 .withBody(getWiremockResponseForCatalogdb(
1274 "vnfComponentRecipeDeleteVfModule_Response.json"))
1275 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1277 // expected response
1278 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1279 RequestReferences requestReferences = new RequestReferences();
1280 requestReferences.setInstanceId("1882939");
1281 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1282 expectedResponse.setRequestReferences(requestReferences);
1283 uri = servInstanceuri + "v6"
1284 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1285 ResponseEntity<String> response =
1286 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1289 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1290 ObjectMapper mapper = new ObjectMapper();
1291 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1292 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1296 public void createVfModuleInstanceNoRecipe() throws IOException {
1298 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1299 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1300 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1301 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1304 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1305 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1306 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1307 .withBody(getWiremockResponseForCatalogdb(
1308 "vnfResourceCustomizationForVfModule_Response.json"))
1309 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1311 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1312 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1313 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1314 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1316 wireMockServer.stubFor(
1317 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1318 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1319 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1320 .withBody(getWiremockResponseForCatalogdb(
1321 "vfModuleCustomizationPCM_Response.json"))
1322 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1324 uri = servInstanceuri + "v6"
1325 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1326 ResponseEntity<String> response =
1327 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1329 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1330 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1331 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1335 public void replaceVfModuleInstance() throws IOException {
1336 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1337 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1338 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1341 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1342 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1343 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1344 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1345 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1347 wireMockServer.stubFor(get(urlMatching(
1348 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1349 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1350 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1351 .withBody(getWiremockResponseForCatalogdb(
1352 "vnfComponentRecipeDeleteVfModule_Response.json"))
1353 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1354 // expected response
1355 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1356 RequestReferences requestReferences = new RequestReferences();
1357 requestReferences.setInstanceId("1882939");
1358 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1359 expectedResponse.setRequestReferences(requestReferences);
1360 uri = servInstanceuri + "v7"
1361 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1362 ResponseEntity<String> response =
1363 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1365 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1366 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1367 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1371 public void updateVfModuleInstance() throws IOException {
1372 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1373 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1374 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1376 wireMockServer.stubFor(get(urlMatching(
1377 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1378 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1379 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1380 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1382 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1383 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1384 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1385 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1387 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1388 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1389 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1390 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1392 wireMockServer.stubFor(get(urlMatching(
1393 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1394 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1395 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1396 .withBody(getWiremockResponseForCatalogdb(
1397 "vnfComponentRecipe_GRAPI_Response.json"))
1398 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1400 // expected response
1401 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1402 RequestReferences requestReferences = new RequestReferences();
1403 requestReferences.setInstanceId("1882939");
1404 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1405 expectedResponse.setRequestReferences(requestReferences);
1406 uri = servInstanceuri + "v7"
1407 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1408 ResponseEntity<String> response =
1409 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1410 logger.debug(response.getBody());
1412 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1413 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1414 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1418 public void createVfModuleNoModelType() throws IOException {
1419 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1420 expectedRecord.setRequestStatus("FAILED");
1421 expectedRecord.setAction("createInstance");
1422 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1423 expectedRecord.setProgress(100L);
1424 expectedRecord.setSource("VID");
1425 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1426 expectedRecord.setLastModifiedBy("APIH");
1427 expectedRecord.setVfModuleName("testVfModule2");
1428 expectedRecord.setVfModuleModelName("serviceModel");
1429 expectedRecord.setRequestScope("vfModule");
1430 expectedRecord.setRequestAction("createInstance");
1431 expectedRecord.setRequestorId("zz9999");
1432 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1433 // VnfType is not sent in this request, should be blank in db
1434 expectedRecord.setVnfType("");
1435 uri = servInstanceuri
1436 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1438 ResponseEntity<String> response =
1439 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1441 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1445 public void inPlaceSoftwareUpdate() throws IOException {
1446 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1447 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1448 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1450 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1451 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1452 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1453 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1454 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1456 // expected response
1457 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1458 RequestReferences requestReferences = new RequestReferences();
1459 requestReferences.setInstanceId("1882939");
1460 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1461 expectedResponse.setRequestReferences(requestReferences);
1462 uri = servInstanceuri + "v7"
1463 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1464 ResponseEntity<String> response =
1465 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1467 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1468 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1469 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1473 public void deleteVfModuleInstance() throws IOException {
1474 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1476 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1479 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1480 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1481 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1482 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1483 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1485 wireMockServer.stubFor(get(urlMatching(
1486 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1487 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1488 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1489 .withBody(getWiremockResponseForCatalogdb(
1490 "vnfComponentRecipeDeleteVfModule_Response.json"))
1491 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1493 // expected response
1494 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1495 RequestReferences requestReferences = new RequestReferences();
1496 requestReferences.setInstanceId("1882939");
1497 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1498 expectedResponse.setRequestReferences(requestReferences);
1499 uri = servInstanceuri + "v7"
1500 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1501 ResponseEntity<String> response =
1502 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1504 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1505 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1506 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1510 public void deleteVfModuleNoModelInvariantId() throws IOException {
1511 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1512 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1513 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1515 wireMockServer.stubFor(get(urlMatching(
1516 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1517 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1518 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1519 .withBody(getWiremockResponseForCatalogdb(
1520 "vnfComponentRecipeDeleteVfModule_Response.json"))
1521 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1523 // expected response
1524 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1525 RequestReferences requestReferences = new RequestReferences();
1526 requestReferences.setInstanceId("1882939");
1527 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1528 expectedResponse.setRequestReferences(requestReferences);
1529 uri = servInstanceuri + "v7"
1530 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1531 ResponseEntity<String> response =
1532 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1534 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1535 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1536 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1540 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1541 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1542 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1543 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1546 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1547 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1548 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1549 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1550 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1552 wireMockServer.stubFor(get(urlMatching(
1553 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1554 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1555 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1556 .withBody(getWiremockResponseForCatalogdb(
1557 "vnfComponentRecipeDeactivate_Response.json"))
1558 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1560 // expected response
1561 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1562 RequestReferences requestReferences = new RequestReferences();
1563 requestReferences.setInstanceId("1882939");
1564 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1565 expectedResponse.setRequestReferences(requestReferences);
1566 uri = servInstanceuri + "v7"
1567 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1568 ResponseEntity<String> response =
1569 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1571 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1572 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1573 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1577 public void createVolumeGroupInstance() throws IOException {
1578 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1579 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1580 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1582 wireMockServer.stubFor(get(urlMatching(
1583 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1584 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1585 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1586 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1588 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1589 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1590 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1591 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1593 wireMockServer.stubFor(get(urlMatching(
1594 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1595 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1596 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1597 .withBody(getWiremockResponseForCatalogdb(
1598 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1599 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1601 // expected response
1602 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1603 RequestReferences requestReferences = new RequestReferences();
1604 requestReferences.setInstanceId("1882939");
1605 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1606 expectedResponse.setRequestReferences(requestReferences);
1607 uri = servInstanceuri + "v7"
1608 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1609 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1611 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1612 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1613 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1614 assertTrue(response.getBody().contains("1882939"));
1618 public void updateVolumeGroupInstance() throws IOException {
1619 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1620 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1621 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1623 wireMockServer.stubFor(get(urlMatching(
1624 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1625 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1626 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1627 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1629 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1630 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1631 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1632 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1634 wireMockServer.stubFor(get(urlMatching(
1635 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1636 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1637 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1638 .withBody(getWiremockResponseForCatalogdb(
1639 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1640 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1642 // expected response
1643 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1644 RequestReferences requestReferences = new RequestReferences();
1645 requestReferences.setInstanceId("1882939");
1646 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1647 expectedResponse.setRequestReferences(requestReferences);
1648 uri = servInstanceuri + "v7"
1649 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1650 ResponseEntity<String> response =
1651 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1653 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1654 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1655 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1659 public void deleteVolumeGroupInstance() throws IOException {
1660 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1661 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1662 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1664 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1665 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1666 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1668 wireMockServer.stubFor(get(urlMatching(
1669 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1670 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1671 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1672 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1674 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1675 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1676 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1677 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1679 wireMockServer.stubFor(get(urlMatching(
1680 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1681 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1682 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1683 .withBody(getWiremockResponseForCatalogdb(
1684 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1685 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1687 // expected response
1688 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1689 RequestReferences requestReferences = new RequestReferences();
1690 requestReferences.setInstanceId("1882939");
1691 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1692 expectedResponse.setRequestReferences(requestReferences);
1693 uri = servInstanceuri + "v7"
1694 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1695 ResponseEntity<String> response =
1696 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1698 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1699 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1700 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1704 public void createNetworkInstance() throws IOException {
1705 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1706 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1707 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1709 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1710 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1711 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1712 .withStatus(HttpStatus.SC_OK)));
1714 wireMockServer.stubFor(
1715 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1717 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1718 .withStatus(HttpStatus.SC_OK)));
1720 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1721 + "modelName=GR-API-DEFAULT&action=createInstance"))
1722 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1723 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1724 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1726 // expected response
1727 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1728 RequestReferences requestReferences = new RequestReferences();
1729 requestReferences.setInstanceId("1882939");
1730 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1731 expectedResponse.setRequestReferences(requestReferences);
1732 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1733 ResponseEntity<String> response =
1734 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1736 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1737 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1738 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1742 public void updateNetworkInstance() throws IOException {
1743 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1744 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1745 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1747 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1748 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1749 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1750 .withStatus(HttpStatus.SC_OK)));
1752 wireMockServer.stubFor(
1753 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1754 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1755 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1756 .withStatus(HttpStatus.SC_OK)));
1758 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1759 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1760 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1761 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1762 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1763 // expected response
1764 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1765 RequestReferences requestReferences = new RequestReferences();
1766 requestReferences.setInstanceId("1882939");
1767 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1768 expectedResponse.setRequestReferences(requestReferences);
1769 uri = servInstanceuri + "v7"
1770 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1771 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1773 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1774 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1775 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1776 assertTrue(response.getBody().contains("1882939"));
1780 public void deleteNetworkInstance() throws IOException {
1781 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1782 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1783 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1785 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1786 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1787 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1788 .withStatus(HttpStatus.SC_OK)));
1790 wireMockServer.stubFor(
1791 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1793 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1794 .withStatus(HttpStatus.SC_OK)));
1796 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1797 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1798 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1799 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1800 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1802 // expected response
1803 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1804 RequestReferences requestReferences = new RequestReferences();
1805 requestReferences.setInstanceId("1882939");
1806 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1807 expectedResponse.setRequestReferences(requestReferences);
1808 uri = servInstanceuri + "v7"
1809 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1810 ResponseEntity<String> response =
1811 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1813 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1814 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1815 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1819 public void deleteNetworkInstanceNoReqParams() throws IOException {
1820 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1821 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1822 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1824 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1825 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1826 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1827 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1828 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1831 // expected response
1832 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1833 RequestReferences requestReferences = new RequestReferences();
1834 requestReferences.setInstanceId("1882939");
1835 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1836 expectedResponse.setRequestReferences(requestReferences);
1837 uri = servInstanceuri + "v6"
1838 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1839 ResponseEntity<String> response =
1840 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1842 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1843 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1844 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1848 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1850 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1851 expectedRecord.setRequestStatus("FAILED");
1852 expectedRecord.setStatusMessage("Error mapping request: ");
1853 expectedRecord.setProgress(100L);
1854 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1855 expectedRecord.setLastModifiedBy("APIH");
1856 expectedRecord.setRequestScope("network");
1857 expectedRecord.setRequestAction("deleteInstance");
1858 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1860 uri = servInstanceuri + "v6"
1861 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1862 ResponseEntity<String> response =
1863 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1867 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1871 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1872 uri = servInstanceuri + "v5"
1873 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1874 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1876 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1880 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1881 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1882 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1883 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1885 ServiceRecipe serviceRecipe = new ServiceRecipe();
1886 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1887 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1888 serviceRecipe.setAction(Action.createInstance.toString());
1889 serviceRecipe.setId(1);
1890 serviceRecipe.setRecipeTimeout(180);
1891 Service defaultService = new Service();
1892 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1894 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1895 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1896 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1898 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1899 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1900 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1902 uri = servInstanceuri + "v7" + "/serviceInstances";
1903 ResponseEntity<String> response =
1904 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1906 // expected response
1907 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1908 RequestReferences requestReferences = new RequestReferences();
1909 requestReferences.setInstanceId("1882939");
1910 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1911 expectedResponse.setRequestReferences(requestReferences);
1913 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1914 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1915 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1919 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1920 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1921 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1922 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1924 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1925 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1926 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1927 .withStatus(HttpStatus.SC_OK)));
1929 wireMockServer.stubFor(
1930 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1931 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1932 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1933 .withStatus(HttpStatus.SC_OK)));
1935 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1936 + "modelName=GR-API-DEFAULT&action=createInstance"))
1937 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1938 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1939 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1941 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1942 ResponseEntity<String> response =
1943 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1945 // expected response
1946 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1947 RequestReferences requestReferences = new RequestReferences();
1948 requestReferences.setInstanceId("1882939");
1949 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1950 expectedResponse.setRequestReferences(requestReferences);
1952 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1953 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1954 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1958 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1959 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1960 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1961 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1963 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1964 ResponseEntity<String> response =
1965 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1967 // expected response
1968 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1969 RequestReferences requestReferences = new RequestReferences();
1970 requestReferences.setInstanceId("1882939");
1971 expectedResponse.setRequestReferences(requestReferences);
1973 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1977 public void createNetworkInstanceTestApiGrApi() throws IOException {
1978 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1979 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1980 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1982 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1983 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1984 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1985 .withStatus(HttpStatus.SC_OK)));
1987 wireMockServer.stubFor(
1988 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1989 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1990 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1991 .withStatus(HttpStatus.SC_OK)));
1993 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1994 + "modelName=GR-API-DEFAULT&action=createInstance"))
1995 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1996 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1997 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1999 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2000 ResponseEntity<String> response =
2001 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2003 // expected response
2004 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2005 RequestReferences requestReferences = new RequestReferences();
2006 requestReferences.setInstanceId("1882939");
2007 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2008 expectedResponse.setRequestReferences(requestReferences);
2010 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2011 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2012 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2016 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2017 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2018 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2019 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2021 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2022 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2023 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2024 .withStatus(HttpStatus.SC_OK)));
2026 wireMockServer.stubFor(
2027 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2028 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2029 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2030 .withStatus(HttpStatus.SC_OK)));
2032 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2033 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2034 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2035 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2036 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2038 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2039 ResponseEntity<String> response =
2040 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2042 // expected response
2043 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2044 RequestReferences requestReferences = new RequestReferences();
2045 requestReferences.setInstanceId("1882939");
2046 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2047 expectedResponse.setRequestReferences(requestReferences);
2049 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2050 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2051 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2055 public void activateServiceInstanceRequestStatus() throws IOException {
2056 ServiceRecipe serviceRecipe = new ServiceRecipe();
2057 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2058 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2059 serviceRecipe.setAction(Action.createInstance.toString());
2060 serviceRecipe.setId(1);
2061 serviceRecipe.setRecipeTimeout(180);
2062 Service defaultService = new Service();
2063 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2065 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2066 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2067 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2069 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2070 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2071 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2073 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2074 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2075 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2078 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2079 RequestReferences requestReferences = new RequestReferences();
2080 requestReferences.setInstanceId("1882939");
2081 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2082 expectedResponse.setRequestReferences(requestReferences);
2083 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2084 ResponseEntity<String> response =
2085 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2087 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2088 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2089 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2093 public void invalidRequestId() throws IOException {
2094 String illegalRequestId = "1234";
2095 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2096 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2097 uri = servInstanceuri + "v5/serviceInstances";
2098 ResponseEntity<String> response =
2099 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2101 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2102 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2106 public void invalidBPELResponse() throws IOException {
2108 ServiceRecipe serviceRecipe = new ServiceRecipe();
2109 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2110 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2111 serviceRecipe.setAction(Action.createInstance.toString());
2112 serviceRecipe.setId(1);
2113 serviceRecipe.setRecipeTimeout(180);
2114 Service defaultService = new Service();
2115 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2117 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2118 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2119 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2121 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2122 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2123 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2125 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2127 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2129 uri = servInstanceuri + "v5/serviceInstances";
2130 ResponseEntity<String> response =
2131 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2133 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2134 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2135 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2136 realResponse.getServiceException().getText());
2140 public void unauthorizedBPELResponse() throws IOException {
2142 ServiceRecipe serviceRecipe = new ServiceRecipe();
2143 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2144 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2145 serviceRecipe.setAction(Action.createInstance.toString());
2146 serviceRecipe.setId(1);
2147 serviceRecipe.setRecipeTimeout(180);
2148 Service defaultService = new Service();
2149 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2151 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2152 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2153 .withBodyFile("Camunda/UnauthorizedResponse.json")
2154 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2156 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2157 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2158 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2160 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2161 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2162 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2164 uri = servInstanceuri + "v5/serviceInstances";
2165 ResponseEntity<String> response =
2166 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2168 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2169 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2170 assertEquals("Exception caught mapping Camunda JSON response to object",
2171 realResponse.getServiceException().getText());
2175 public void invalidBPELResponse2() throws IOException {
2177 ServiceRecipe serviceRecipe = new ServiceRecipe();
2178 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2179 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2180 serviceRecipe.setAction(Action.createInstance.toString());
2181 serviceRecipe.setId(1);
2182 serviceRecipe.setRecipeTimeout(180);
2183 Service defaultService = new Service();
2184 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2186 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2187 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2188 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2190 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2191 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2192 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2194 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2195 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2196 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2197 uri = servInstanceuri + "v5/serviceInstances";
2198 ResponseEntity<String> response =
2199 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2201 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2202 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2203 assertTrue(realResponse.getServiceException().getText()
2204 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2208 public void createMacroServiceInstance() throws IOException {
2209 ServiceRecipe serviceRecipe = new ServiceRecipe();
2210 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2211 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2212 serviceRecipe.setAction(Action.createInstance.toString());
2213 serviceRecipe.setId(1);
2214 serviceRecipe.setRecipeTimeout(180);
2215 Service defaultService = new Service();
2216 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2218 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2219 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2220 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2222 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2223 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2224 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2226 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2227 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2228 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2230 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2231 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2232 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2235 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2236 RequestReferences requestReferences = new RequestReferences();
2237 requestReferences.setInstanceId("1882939");
2238 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2239 expectedResponse.setRequestReferences(requestReferences);
2240 uri = servInstanceUriPrev7 + "v5";
2241 ResponseEntity<String> response =
2242 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2245 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2246 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2247 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2251 public void testUserParams() throws IOException {
2252 ObjectMapper mapper = new ObjectMapper();
2253 ServiceInstancesRequest request =
2254 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2255 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2256 String userParamsTxt = inputStream("/userParams.txt");
2258 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2259 System.out.println(userParams);
2260 assertTrue(userParams.size() > 0);
2261 assertTrue(userParams.get(0).containsKey("name"));
2262 assertTrue(userParams.get(0).containsKey("value"));
2263 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2267 public void testConfigureCloudConfig() throws IOException {
2268 ObjectMapper mapper = new ObjectMapper();
2269 ServiceInstancesRequest request =
2270 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2271 CloudConfiguration cloudConfig =
2272 servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2274 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2275 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2279 public void testMapToLegacyRequest() throws IOException {
2280 ObjectMapper mapper = new ObjectMapper();
2281 ServiceInstancesRequest request =
2282 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2283 ServiceInstancesRequest expected =
2284 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2285 servInstances.mapToLegacyRequest(request.getRequestDetails());
2286 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2287 assertThat(request, sameBeanAs(expected));
2291 public void scaleOutVfModule() throws IOException {
2292 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2293 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2294 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2296 wireMockServer.stubFor(get(urlMatching(
2297 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2298 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2299 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2300 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2302 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2303 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2304 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2305 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2307 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2308 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2309 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2310 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2313 wireMockServer.stubFor(get(urlMatching(
2314 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2315 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2316 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2317 .withBody(getWiremockResponseForCatalogdb(
2318 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2319 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2321 wireMockServer.stubFor(get(urlMatching(
2322 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2323 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2324 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2325 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2327 // expected response
2328 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2329 RequestReferences requestReferences = new RequestReferences();
2330 requestReferences.setInstanceId("1882939");
2331 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2332 expectedResponse.setRequestReferences(requestReferences);
2333 uri = servInstanceuri + "v7"
2334 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2335 ResponseEntity<String> response =
2336 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2338 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2339 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2340 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2341 assertTrue(response.getBody().contains("1882939"));
2345 public void createServiceInstanceBadResponse() throws IOException {
2346 ServiceRecipe serviceRecipe = new ServiceRecipe();
2347 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2348 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2349 serviceRecipe.setAction(Action.createInstance.toString());
2350 serviceRecipe.setId(1);
2351 serviceRecipe.setRecipeTimeout(180);
2352 Service defaultService = new Service();
2353 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2355 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2356 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2357 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2359 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2360 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2361 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2363 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2365 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2367 uri = servInstanceuri + "v5/serviceInstances";
2368 ResponseEntity<String> response =
2369 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2371 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2372 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2373 assertEquals("Exception caught mapping Camunda JSON response to object",
2374 realResponse.getServiceException().getText());
2378 public void createServiceInstanceDuplicateError() throws IOException {
2379 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2380 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2381 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2383 uri = servInstanceuri + "v5/serviceInstances";
2384 ResponseEntity<String> response =
2385 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2387 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2388 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2390 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2391 realResponse.getServiceException().getText());
2395 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2396 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2397 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2398 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2399 .withStatus(HttpStatus.SC_ACCEPTED)));
2400 wireMockServer.stubFor(get(
2401 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2402 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2403 .withBodyFile("Camunda/HistoryCheckResponse.json")
2404 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2406 uri = servInstanceuri + "v5/serviceInstances";
2407 ResponseEntity<String> response =
2408 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2410 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2411 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2413 "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.",
2414 realResponse.getServiceException().getText());
2418 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2419 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2420 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2421 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2422 .withStatus(HttpStatus.SC_ACCEPTED)));
2423 wireMockServer.stubFor(get(
2424 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2425 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2426 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2428 uri = servInstanceuri + "v5/serviceInstances";
2429 ResponseEntity<String> response =
2430 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2432 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2433 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2435 "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",
2436 realResponse.getServiceException().getText());
2440 public void createServiceInstanceDuplicate() throws IOException {
2441 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2442 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2443 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2445 uri = servInstanceuri + "v5/serviceInstances";
2446 ResponseEntity<String> response =
2447 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2449 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2450 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2452 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2453 realResponse.getServiceException().getText());
2457 public void createServiceInstanceSaveError() throws IOException {
2458 ServiceRecipe serviceRecipe = new ServiceRecipe();
2459 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2460 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2461 serviceRecipe.setAction(Action.createInstance.toString());
2462 serviceRecipe.setId(1);
2463 serviceRecipe.setRecipeTimeout(180);
2464 Service defaultService = new Service();
2465 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2466 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2467 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2468 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2469 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2470 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2471 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2473 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2474 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2475 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2477 uri = servInstanceuri + "v5/serviceInstances";
2478 ResponseEntity<String> response =
2479 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2481 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2482 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2484 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2485 realResponse.getServiceException().getText());
2489 public void createPortConfigurationSaveError() throws IOException {
2490 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2491 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2492 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2493 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2495 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2497 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2498 ResponseEntity<String> response =
2499 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2501 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2502 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2504 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2505 realResponse.getServiceException().getText());
2509 public void createPortConfigDbUpdateError() throws IOException {
2510 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2511 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2512 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2514 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2515 ResponseEntity<String> response =
2516 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2518 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2519 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2521 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error",
2522 realResponse.getServiceException().getText());
2526 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2527 TestAppender.events.clear();
2528 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2530 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2532 wireMockServer.stubFor(get(urlMatching(
2533 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2534 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2535 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2536 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2538 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2539 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2540 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2541 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2543 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2544 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2545 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2546 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2547 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2548 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2550 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2551 RequestReferences requestReferences = new RequestReferences();
2552 requestReferences.setInstanceId("1882939");
2553 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2554 expectedResponse.setRequestReferences(requestReferences);
2555 uri = servInstanceuri
2556 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2557 ResponseEntity<String> response =
2558 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2560 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2561 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2562 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2563 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2565 for (ILoggingEvent logEvent : TestAppender.events) {
2566 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging")
2567 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
2568 Map<String, String> mdc = logEvent.getMDCPropertyMap();
2569 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2570 assertEquals("VID", mdc.get(PARTNERNAME));
2576 public void createInstanceGroup() throws IOException {
2577 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2578 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2579 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2582 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2583 RequestReferences requestReferences = new RequestReferences();
2584 requestReferences.setInstanceId("1882939");
2585 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2586 expectedResponse.setRequestReferences(requestReferences);
2587 uri = servInstanceuri + "/v7/instanceGroups";
2588 ResponseEntity<String> response =
2589 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2592 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2593 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2594 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2598 public void deleteInstanceGroup() throws IOException {
2599 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2601 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2604 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2605 RequestReferences requestReferences = new RequestReferences();
2606 requestReferences.setInstanceId("1882939");
2607 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2608 expectedResponse.setRequestReferences(requestReferences);
2609 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2610 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2613 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2614 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2615 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2619 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2620 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2621 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2623 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2624 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2625 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2629 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2630 HttpHeaders noPartnerHeaders = new HttpHeaders();
2631 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2632 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2633 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2634 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2636 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2637 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2638 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2642 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2643 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2644 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2645 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2647 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2648 RequestReferences requestReferences = new RequestReferences();
2649 requestReferences.setInstanceId("1882939");
2650 expectedResponse.setRequestReferences(requestReferences);
2651 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2652 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2655 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2656 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2657 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2661 public void addMembers() throws IOException {
2662 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2663 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2664 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2666 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2667 RequestReferences requestReferences = new RequestReferences();
2668 requestReferences.setInstanceId("1882939");
2669 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2670 expectedResponse.setRequestReferences(requestReferences);
2671 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2672 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2675 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2676 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2677 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2681 public void removeMembers() throws IOException {
2682 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2683 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2684 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2686 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2687 RequestReferences requestReferences = new RequestReferences();
2688 requestReferences.setInstanceId("1882939");
2689 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2690 expectedResponse.setRequestReferences(requestReferences);
2691 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2692 ResponseEntity<String> response =
2693 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2696 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2697 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2698 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2702 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2703 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2704 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2705 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2707 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2708 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2709 .withStatus(HttpStatus.SC_NOT_FOUND)));
2711 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2712 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2713 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2714 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2715 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2717 // expected response
2718 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2719 RequestReferences requestReferences = new RequestReferences();
2720 requestReferences.setInstanceId("1882939");
2721 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2722 expectedResponse.setRequestReferences(requestReferences);
2723 uri = servInstanceuri + "v7"
2724 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2725 ResponseEntity<String> response =
2726 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2728 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2729 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2730 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2734 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2735 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2736 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2737 .withStatus(HttpStatus.SC_NOT_FOUND)));
2739 uri = servInstanceuri + "v7"
2740 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2741 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2743 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2744 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2745 assertEquals(realResponse.getServiceException().getText(),
2746 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");