2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.apihandlerinfra;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
29 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertFalse;
32 import static org.junit.Assert.assertNotNull;
33 import static org.junit.Assert.assertNull;
34 import static org.junit.Assert.assertThat;
35 import static org.junit.Assert.assertTrue;
36 import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
37 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
38 import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID;
39 import static org.onap.logging.filter.base.Constants.HttpHeaders.CLIENT_ID;
41 import java.io.IOException;
42 import java.net.MalformedURLException;
44 import java.nio.file.Files;
45 import java.nio.file.Paths;
46 import java.util.List;
48 import javax.ws.rs.core.MediaType;
49 import javax.ws.rs.core.Response;
50 import org.apache.http.HttpStatus;
51 import org.junit.Before;
52 import org.junit.Test;
53 import org.mockito.Mockito;
54 import org.onap.logging.ref.slf4j.ONAPLogConstants;
55 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
56 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
57 import org.onap.so.db.catalog.beans.Service;
58 import org.onap.so.db.catalog.beans.ServiceRecipe;
59 import org.onap.so.db.request.beans.InfraActiveRequests;
60 import org.onap.so.serviceinstancebeans.CloudConfiguration;
61 import org.onap.so.serviceinstancebeans.ModelInfo;
62 import org.onap.so.serviceinstancebeans.ModelType;
63 import org.onap.so.serviceinstancebeans.RequestDetails;
64 import org.onap.so.serviceinstancebeans.RequestError;
65 import org.onap.so.serviceinstancebeans.RequestInfo;
66 import org.onap.so.serviceinstancebeans.RequestParameters;
67 import org.onap.so.serviceinstancebeans.RequestReferences;
68 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
69 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
70 import org.springframework.beans.factory.annotation.Autowired;
71 import org.springframework.beans.factory.annotation.Value;
72 import org.springframework.http.HttpEntity;
73 import org.springframework.http.HttpHeaders;
74 import org.springframework.http.HttpMethod;
75 import org.springframework.http.ResponseEntity;
76 import org.springframework.util.ResourceUtils;
77 import org.springframework.web.util.UriComponentsBuilder;
78 import com.fasterxml.jackson.core.JsonParseException;
79 import com.fasterxml.jackson.core.JsonProcessingException;
80 import com.fasterxml.jackson.databind.DeserializationFeature;
81 import com.fasterxml.jackson.databind.JsonMappingException;
82 import com.fasterxml.jackson.databind.ObjectMapper;
83 import com.github.tomakehurst.wiremock.http.Fault;
84 import ch.qos.logback.classic.spi.ILoggingEvent;
86 public class ServiceInstancesTest extends BaseTest {
88 private final ObjectMapper mapper = new ObjectMapper();
91 private ServiceInstances servInstances;
94 private RequestHandlerUtils requestHandlerUtils;
96 @Value("${wiremock.server.port}")
97 private String wiremockPort;
99 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
100 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
102 private URL selfLink;
103 private URL initialUrl;
104 private int initialPort;
105 private HttpHeaders headers;
108 public void beforeClass() {
109 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
111 headers = new HttpHeaders();
112 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
113 headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
114 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
115 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
116 headers.set(CLIENT_ID, "VID");
117 headers.set(REQUESTOR_ID, "xxxxxx");
118 try { // generate one-time port number to avoid RANDOM port number later.
119 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
120 initialPort = initialUrl.getPort();
121 } catch (MalformedURLException e) {
124 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/")).willReturn(aResponse()
125 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
126 Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
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.SOAuditLogContainerFilter")
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(ONAPLogConstants.MDCs.INVOCATION_ID));
227 assertEquals("UNKNOWN", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
228 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",
229 mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
230 assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
231 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter")
232 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
233 Map<String, String> mdc = logEvent.getMDCPropertyMap();
234 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
235 assertNotNull(mdc.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP));
236 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
237 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
238 assertEquals("202", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
239 assertEquals("UNKNOWN", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
240 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",
241 mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
242 assertEquals("COMPLETE", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
243 assertNotNull(mdc.get(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION));
244 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
245 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
246 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
251 public void createServiceInstanceServiceInstancesUri() throws IOException {
252 ServiceRecipe serviceRecipe = new ServiceRecipe();
253 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
254 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
255 serviceRecipe.setAction(Action.createInstance.toString());
256 serviceRecipe.setId(1);
257 serviceRecipe.setRecipeTimeout(180);
258 Service defaultService = new Service();
259 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
261 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
262 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
263 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
266 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
267 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
268 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
270 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
272 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
274 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
275 RequestReferences requestReferences = new RequestReferences();
276 requestReferences.setInstanceId("1882939");
277 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
278 expectedResponse.setRequestReferences(requestReferences);
279 uri = servInstanceuri + "v5";
280 ResponseEntity<String> response =
281 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
284 assertEquals(404, response.getStatusCode().value());
285 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
289 public void createServiceInstanceBpelStatusError() throws IOException {
290 ServiceRecipe serviceRecipe = new ServiceRecipe();
291 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
292 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
293 serviceRecipe.setAction(Action.createInstance.toString());
294 serviceRecipe.setId(1);
295 serviceRecipe.setRecipeTimeout(180);
296 Service defaultService = new Service();
297 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
300 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
301 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
302 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
305 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
306 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
307 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
309 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
310 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
311 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
313 uri = servInstanceuri + "v5/serviceInstances";
314 ResponseEntity<String> response =
315 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
317 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
321 public void createServiceInstanceBadGateway() throws IOException {
322 ServiceRecipe serviceRecipe = new ServiceRecipe();
323 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
324 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
325 serviceRecipe.setAction(Action.createInstance.toString());
326 serviceRecipe.setId(1);
327 serviceRecipe.setRecipeTimeout(180);
328 Service defaultService = new Service();
329 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
331 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
332 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
334 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
335 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
336 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
338 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
339 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
340 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
342 uri = servInstanceuri + "v5/serviceInstances";
343 ResponseEntity<String> response =
344 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
346 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
350 public void createServiceInstanceEmptyResponse() throws IOException {
351 ServiceRecipe serviceRecipe = new ServiceRecipe();
352 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
353 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
354 serviceRecipe.setAction(Action.createInstance.toString());
355 serviceRecipe.setId(1);
356 serviceRecipe.setRecipeTimeout(180);
357 Service defaultService = new Service();
358 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
360 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
361 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
363 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
365 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
367 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
368 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
369 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
371 uri = servInstanceuri + "v5/serviceInstances";
372 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
374 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
378 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
379 TestAppender.events.clear();
380 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
381 HttpHeaders requestIDheaders = new HttpHeaders();
382 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
383 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
384 HttpMethod.POST, requestIDheaders);
386 Service defaultService = new Service();
387 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
389 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
390 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
391 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
394 wireMockServer.stubFor(get(urlMatching(
395 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
396 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
397 .withStatus(HttpStatus.SC_NOT_FOUND)));
399 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
401 for (ILoggingEvent logEvent : TestAppender.events) {
402 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.SOAuditLogContainerFilter")
403 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
404 Map<String, String> mdc = logEvent.getMDCPropertyMap();
405 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
406 assertNotNull(mdc.get("PartnerName"));
412 public void activateServiceInstanceNoRecipe() throws IOException {
413 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
414 Service defaultService = new Service();
415 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
416 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
417 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
418 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
420 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
421 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
423 ResponseEntity<String> response =
424 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
426 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
430 public void activateServiceInstance() throws IOException {
431 ServiceRecipe serviceRecipe = new ServiceRecipe();
432 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
433 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
434 serviceRecipe.setAction(Action.createInstance.toString());
435 serviceRecipe.setId(1);
436 serviceRecipe.setRecipeTimeout(180);
437 Service defaultService = new Service();
438 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
440 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
441 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
442 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
444 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
445 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
446 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
448 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
449 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
450 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
452 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
453 RequestReferences requestReferences = new RequestReferences();
454 requestReferences.setInstanceId("1882939");
455 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
456 expectedResponse.setRequestReferences(requestReferences);
457 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
458 ResponseEntity<String> response =
459 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
461 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
462 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
463 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
467 public void deactivateServiceInstance() throws IOException {
469 ServiceRecipe serviceRecipe = new ServiceRecipe();
470 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
471 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
472 serviceRecipe.setAction(Action.createInstance.toString());
473 serviceRecipe.setId(1);
474 serviceRecipe.setRecipeTimeout(180);
475 Service defaultService = new Service();
476 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
478 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
479 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
480 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
482 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
483 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
484 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
486 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
487 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
488 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
490 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
491 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
492 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
495 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
496 RequestReferences requestReferences = new RequestReferences();
497 requestReferences.setInstanceId("1882939");
498 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
499 expectedResponse.setRequestReferences(requestReferences);
500 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
501 ResponseEntity<String> response =
502 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
504 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
505 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
506 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
510 public void deleteServiceInstance() throws IOException {
511 ServiceRecipe serviceRecipe = new ServiceRecipe();
512 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
513 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
514 serviceRecipe.setAction(Action.createInstance.toString());
515 serviceRecipe.setId(1);
516 serviceRecipe.setRecipeTimeout(180);
517 Service defaultService = new Service();
518 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
520 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
522 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
524 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
526 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
528 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
530 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
532 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
533 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
534 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
536 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
537 RequestReferences requestReferences = new RequestReferences();
538 requestReferences.setInstanceId("1882939");
539 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
540 expectedResponse.setRequestReferences(requestReferences);
541 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
542 ResponseEntity<String> response =
543 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
545 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
546 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
547 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
551 public void assignServiceInstance() throws IOException {
552 ServiceRecipe serviceRecipe = new ServiceRecipe();
553 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
554 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
555 serviceRecipe.setAction(Action.createInstance.toString());
556 serviceRecipe.setId(1);
557 serviceRecipe.setRecipeTimeout(180);
558 Service defaultService = new Service();
559 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
561 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
562 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
563 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
565 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
566 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
567 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
569 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
570 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
571 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
573 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
574 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
575 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
577 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
578 RequestReferences requestReferences = new RequestReferences();
579 requestReferences.setInstanceId("1882939");
580 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
581 expectedResponse.setRequestReferences(requestReferences);
582 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
583 ResponseEntity<String> response =
584 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
586 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
587 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
588 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
592 public void unassignServiceInstance() throws IOException {
593 ServiceRecipe serviceRecipe = new ServiceRecipe();
594 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
595 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
596 serviceRecipe.setAction(Action.createInstance.toString());
597 serviceRecipe.setId(1);
598 serviceRecipe.setRecipeTimeout(180);
599 Service defaultService = new Service();
600 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
602 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
604 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
606 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
607 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
608 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
610 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
611 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
612 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
614 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
615 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
616 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
618 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
619 RequestReferences requestReferences = new RequestReferences();
620 requestReferences.setInstanceId("1882939");
621 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
622 expectedResponse.setRequestReferences(requestReferences);
623 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
624 ResponseEntity<String> response =
625 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
627 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
628 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
629 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
633 public void createPortConfiguration() throws IOException {
634 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
635 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
636 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
638 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
639 RequestReferences requestReferences = new RequestReferences();
640 requestReferences.setInstanceId("1882939");
641 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
642 expectedResponse.setRequestReferences(requestReferences);
643 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
644 ResponseEntity<String> response =
645 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
647 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
648 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
649 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
650 assertTrue(response.getBody().contains("1882939"));
654 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
655 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
656 ResponseEntity<String> response =
657 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
659 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
663 public void deletePortConfiguration() throws IOException {
664 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
665 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
666 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
669 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
670 RequestReferences requestReferences = new RequestReferences();
671 requestReferences.setInstanceId("1882939");
672 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
673 expectedResponse.setRequestReferences(requestReferences);
674 uri = servInstanceuri + "v7"
675 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
676 ResponseEntity<String> response =
677 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
679 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
680 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
681 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
685 public void enablePort() throws IOException {
686 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
687 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
688 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
690 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
691 RequestReferences requestReferences = new RequestReferences();
692 requestReferences.setInstanceId("1882939");
693 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
694 expectedResponse.setRequestReferences(requestReferences);
695 uri = servInstanceuri + "v7"
696 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
697 ResponseEntity<String> response =
698 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
700 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
701 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
702 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
706 public void disablePort() throws IOException {
707 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
708 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
709 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
711 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
712 RequestReferences requestReferences = new RequestReferences();
713 requestReferences.setInstanceId("1882939");
714 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
715 expectedResponse.setRequestReferences(requestReferences);
716 uri = servInstanceuri + "v7"
717 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
718 ResponseEntity<String> response =
719 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
721 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
722 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
723 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
727 public void activatePort() throws IOException {
728 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
729 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
730 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
732 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
733 RequestReferences requestReferences = new RequestReferences();
734 requestReferences.setInstanceId("1882939");
735 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
736 expectedResponse.setRequestReferences(requestReferences);
737 uri = servInstanceuri + "v7"
738 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
739 ResponseEntity<String> response =
740 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
742 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
743 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
744 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
748 public void deactivatePort() throws IOException {
749 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
750 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
751 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
753 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
754 RequestReferences requestReferences = new RequestReferences();
755 requestReferences.setInstanceId("1882939");
756 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
757 expectedResponse.setRequestReferences(requestReferences);
758 uri = servInstanceuri + "v7"
759 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
760 ResponseEntity<String> response =
761 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
763 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
764 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
765 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
769 public void addRelationships() throws IOException {
770 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
771 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
772 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
774 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
775 RequestReferences requestReferences = new RequestReferences();
776 requestReferences.setInstanceId("1882939");
777 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
778 expectedResponse.setRequestReferences(requestReferences);
779 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
780 ResponseEntity<String> response =
781 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
783 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
784 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
785 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
789 public void removeRelationships() throws IOException {
790 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
791 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
792 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
794 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
795 RequestReferences requestReferences = new RequestReferences();
796 requestReferences.setInstanceId("1882939");
797 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
798 expectedResponse.setRequestReferences(requestReferences);
799 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
800 ResponseEntity<String> response =
801 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
803 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
804 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
805 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
809 public void createVnfInstanceNoALaCarte() throws IOException {
810 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
812 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
815 wireMockServer.stubFor(get(urlMatching(
816 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
817 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
818 .withBody(getWiremockResponseForCatalogdb(
819 "vnfResourceCustomization_ReplaceVnf_Response.json"))
820 .withStatus(org.apache.http.HttpStatus.SC_OK)));
822 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
823 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
824 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
825 .withStatus(org.apache.http.HttpStatus.SC_OK)));
827 wireMockServer.stubFor(get(urlMatching(
828 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
829 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
830 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
831 .withStatus(org.apache.http.HttpStatus.SC_OK)));
834 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
835 RequestReferences requestReferences = new RequestReferences();
836 requestReferences.setInstanceId("1882939");
837 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
838 expectedResponse.setRequestReferences(requestReferences);
839 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
840 ResponseEntity<String> response =
841 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
843 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
844 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
845 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
849 public void createVnfInstance() throws IOException {
850 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
851 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
852 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
854 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
855 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
856 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
857 .withStatus(org.apache.http.HttpStatus.SC_OK)));
858 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
859 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
860 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
861 .withStatus(org.apache.http.HttpStatus.SC_OK)));
864 wireMockServer.stubFor(
865 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
866 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
867 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
868 .withStatus(org.apache.http.HttpStatus.SC_OK)));
870 wireMockServer.stubFor(get(urlMatching(
871 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
872 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
873 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
874 .withStatus(org.apache.http.HttpStatus.SC_OK)));
877 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
878 RequestReferences requestReferences = new RequestReferences();
879 requestReferences.setInstanceId("1882939");
880 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
881 expectedResponse.setRequestReferences(requestReferences);
882 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
883 ResponseEntity<String> response =
884 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
886 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
887 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
888 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
889 assertTrue(response.getBody().contains("1882939"));
893 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
894 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
895 ResponseEntity<String> response =
896 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
898 assertEquals(404, response.getStatusCode().value());
902 public void createVnfInstanceInvalidVnfResource() throws IOException {
903 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
904 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
906 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
907 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
908 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
912 public void replaceVnfInstance() throws IOException {
913 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
914 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
915 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
917 wireMockServer.stubFor(get(urlMatching(
918 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
919 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
920 .withBody(getWiremockResponseForCatalogdb(
921 "vnfResourceCustomization_ReplaceVnf_Response.json"))
922 .withStatus(org.apache.http.HttpStatus.SC_OK)));
924 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
925 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
926 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
927 .withStatus(org.apache.http.HttpStatus.SC_OK)));
929 wireMockServer.stubFor(get(urlMatching(
930 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
931 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
932 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
933 .withStatus(org.apache.http.HttpStatus.SC_OK)));
935 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
936 RequestReferences requestReferences = new RequestReferences();
937 requestReferences.setInstanceId("1882939");
938 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
939 expectedResponse.setRequestReferences(requestReferences);
940 uri = servInstanceuri + "v7"
941 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
942 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
944 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
945 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
946 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
950 public void replaceVnfInstanceNoCloudConfig() throws IOException {
951 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/v1/getInfraActiveRequests.*"))
952 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
953 .withBodyFile("infra/VnfLookup.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
954 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
955 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
956 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
957 wireMockServer.stubFor(get(urlMatching(
958 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
959 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
960 .withBody(getWiremockResponseForCatalogdb(
961 "vnfResourceCustomization_ReplaceVnf_Response.json"))
962 .withStatus(org.apache.http.HttpStatus.SC_OK)));
963 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
964 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
965 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
966 .withStatus(org.apache.http.HttpStatus.SC_OK)));
967 wireMockServer.stubFor(get(urlMatching(
968 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
969 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
970 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
971 .withStatus(org.apache.http.HttpStatus.SC_OK)));
973 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
974 RequestReferences requestReferences = new RequestReferences();
975 requestReferences.setInstanceId("1882939");
976 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
977 expectedResponse.setRequestReferences(requestReferences);
978 uri = servInstanceuri + "v7"
979 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
980 ResponseEntity<String> response =
981 sendRequest(inputStream("/ReplaceVnfNoCloudConfig.json"), uri, HttpMethod.POST, headers);
983 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
984 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
985 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
989 public void replaceVnfRecreateInstance() throws IOException {
990 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
991 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
992 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
994 wireMockServer.stubFor(get(urlMatching(
995 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
996 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
997 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
998 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1000 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1001 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1002 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1003 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1005 wireMockServer.stubFor(get(urlMatching(
1006 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
1007 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1008 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
1009 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1011 // expected response
1012 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1013 RequestReferences requestReferences = new RequestReferences();
1014 requestReferences.setInstanceId("1882939");
1015 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1016 expectedResponse.setRequestReferences(requestReferences);
1017 uri = servInstanceuri + "v7"
1018 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1019 ResponseEntity<String> response =
1020 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
1021 logger.debug(response.getBody());
1023 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1024 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1025 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1029 public void recreateVnfInstance() throws IOException {
1030 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1031 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1032 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1034 wireMockServer.stubFor(get(urlMatching(
1035 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1036 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1037 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
1038 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1040 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1041 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1042 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1043 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1045 wireMockServer.stubFor(get(urlMatching(
1046 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1048 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1049 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1051 // expected response
1052 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1053 RequestReferences requestReferences = new RequestReferences();
1054 requestReferences.setInstanceId("1882939");
1055 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1056 expectedResponse.setRequestReferences(requestReferences);
1057 uri = servInstanceuri + "v7"
1058 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1059 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1060 logger.debug(response.getBody());
1062 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1063 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1064 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1068 public void updateVnfInstance() throws IOException {
1069 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1070 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1071 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1073 wireMockServer.stubFor(get(urlMatching(
1074 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1076 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1077 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1079 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1081 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1082 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1084 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1085 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1086 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1087 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1088 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1090 // expected response
1091 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1092 RequestReferences requestReferences = new RequestReferences();
1093 requestReferences.setInstanceId("1882939");
1094 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1095 expectedResponse.setRequestReferences(requestReferences);
1096 uri = servInstanceuri + "v7"
1097 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1098 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1100 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1101 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1102 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1106 public void applyUpdatedConfig() throws IOException {
1107 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1108 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1109 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1112 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1113 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1114 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1115 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1116 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1118 // expected response
1119 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1120 RequestReferences requestReferences = new RequestReferences();
1121 requestReferences.setInstanceId("1882939");
1122 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1123 expectedResponse.setRequestReferences(requestReferences);
1124 uri = servInstanceuri + "v7"
1125 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1126 ResponseEntity<String> response =
1127 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1129 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1130 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1131 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1135 public void deleteVnfInstanceV5() throws IOException {
1136 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
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(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1141 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1142 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1143 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1144 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1145 // expected response
1146 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1147 RequestReferences requestReferences = new RequestReferences();
1148 requestReferences.setInstanceId("1882939");
1149 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1150 expectedResponse.setRequestReferences(requestReferences);
1151 uri = servInstanceuri + "v5"
1152 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1153 ResponseEntity<String> response =
1154 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1156 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1157 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1158 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1162 public void createVfModuleInstance() throws IOException {
1163 wireMockServer.stubFor(get(urlMatching(
1164 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1165 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1166 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1167 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1169 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1170 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1171 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1172 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1174 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1175 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1176 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1177 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1179 wireMockServer.stubFor(get(urlMatching(
1180 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1181 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1182 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1183 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1185 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1186 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1187 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1189 wireMockServer.stubFor(get(urlMatching(
1190 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1191 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1192 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1193 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1194 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1195 // expected response
1196 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1197 RequestReferences requestReferences = new RequestReferences();
1198 requestReferences.setInstanceId("1882939");
1199 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1200 expectedResponse.setRequestReferences(requestReferences);
1201 uri = servInstanceuri + "v7"
1202 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1203 ResponseEntity<String> response =
1204 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1206 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1207 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1208 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1209 assertTrue(response.getBody().contains("1882939"));
1213 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1214 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1215 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1216 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1218 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1219 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1220 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1221 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1224 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1225 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1226 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1227 .withBody(getWiremockResponseForCatalogdb(
1228 "vnfResourceCustomizationForVfModule_Response.json"))
1229 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1231 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1232 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1233 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1234 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1236 wireMockServer.stubFor(get(urlMatching(
1237 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1238 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1239 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1240 .withBody(getWiremockResponseForCatalogdb(
1241 "vfModuleCustomizationPCM_Response.json"))
1242 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1244 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1245 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1246 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1247 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1249 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1250 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1251 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1252 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1255 wireMockServer.stubFor(
1256 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1257 + "[?]vnfComponentType=vfModule&action=createInstance"))
1258 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1259 .withBody(getWiremockResponseForCatalogdb(
1260 "vnfComponentRecipeVNF_API_Response.json"))
1261 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1263 // expected response
1264 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1265 RequestReferences requestReferences = new RequestReferences();
1266 requestReferences.setInstanceId("1882939");
1267 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1268 expectedResponse.setRequestReferences(requestReferences);
1269 uri = servInstanceuri + "v6"
1270 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1271 ResponseEntity<String> response =
1272 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1273 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1274 ObjectMapper mapper = new ObjectMapper();
1275 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1276 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1280 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1281 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1282 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1283 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1285 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1286 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1287 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1288 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1291 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1292 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1293 .withBody(getWiremockResponseForCatalogdb(
1294 "vnfResourceCustomizationForVfModule_Response.json"))
1295 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1297 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1298 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1299 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1300 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1302 wireMockServer.stubFor(get(urlMatching(
1303 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1304 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1305 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1306 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1308 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1310 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1311 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1313 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1314 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1315 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1316 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1318 wireMockServer.stubFor(get(urlMatching(
1319 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1320 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1321 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1322 .withBody(getWiremockResponseForCatalogdb(
1323 "vnfComponentRecipeDeleteVfModule_Response.json"))
1324 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1326 // expected response
1327 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1328 RequestReferences requestReferences = new RequestReferences();
1329 requestReferences.setInstanceId("1882939");
1330 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1331 expectedResponse.setRequestReferences(requestReferences);
1332 uri = servInstanceuri + "v6"
1333 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1334 ResponseEntity<String> response =
1335 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1338 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1339 ObjectMapper mapper = new ObjectMapper();
1340 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1341 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1345 public void createVfModuleInstanceNoRecipe() throws IOException {
1347 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1348 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1349 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1350 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1353 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1354 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1355 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1356 .withBody(getWiremockResponseForCatalogdb(
1357 "vnfResourceCustomizationForVfModule_Response.json"))
1358 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1360 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1361 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1362 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1363 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1365 wireMockServer.stubFor(
1366 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1367 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1368 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1369 .withBody(getWiremockResponseForCatalogdb(
1370 "vfModuleCustomizationPCM_Response.json"))
1371 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1373 uri = servInstanceuri + "v6"
1374 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1375 ResponseEntity<String> response =
1376 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1378 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1379 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1380 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1384 public void replaceVfModuleInstance() throws IOException {
1385 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1386 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1387 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1390 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1391 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1392 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1393 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1394 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1396 wireMockServer.stubFor(get(urlMatching(
1397 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1398 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1400 .withBody(getWiremockResponseForCatalogdb(
1401 "vnfComponentRecipeDeleteVfModule_Response.json"))
1402 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1403 // expected response
1404 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1405 RequestReferences requestReferences = new RequestReferences();
1406 requestReferences.setInstanceId("1882939");
1407 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1408 expectedResponse.setRequestReferences(requestReferences);
1409 uri = servInstanceuri + "v7"
1410 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1411 ResponseEntity<String> response =
1412 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1414 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1415 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1416 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1420 public void replaceVfModuleInstanceNoCloudConfigurationTest() throws IOException {
1421 wireMockServer.stubFor(
1422 get(urlPathEqualTo("/aai/v17/network/generic-vnfs/generic-vnf/ff305d54-75b4-431b-adb2-eb6b9e5ff000"))
1423 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1424 .withBodyFile("infra/Vnf.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1425 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1426 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1427 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1429 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1430 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1431 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1432 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1433 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1434 wireMockServer.stubFor(get(urlMatching(
1435 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1436 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1437 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1438 .withBody(getWiremockResponseForCatalogdb(
1439 "vnfComponentRecipeDeleteVfModule_Response.json"))
1440 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1441 // expected response
1442 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1443 RequestReferences requestReferences = new RequestReferences();
1444 requestReferences.setInstanceId("1882939");
1445 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1446 expectedResponse.setRequestReferences(requestReferences);
1447 uri = servInstanceuri + "v7"
1448 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1449 ResponseEntity<String> response =
1450 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
1452 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1453 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1454 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1458 public void updateVfModuleInstance() throws IOException {
1459 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1460 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1461 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1463 wireMockServer.stubFor(get(urlMatching(
1464 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1465 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1466 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1467 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1469 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1470 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1471 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1472 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1474 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1476 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1477 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1479 wireMockServer.stubFor(get(urlMatching(
1480 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1481 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1482 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1483 .withBody(getWiremockResponseForCatalogdb(
1484 "vnfComponentRecipe_GRAPI_Response.json"))
1485 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1487 // expected response
1488 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1489 RequestReferences requestReferences = new RequestReferences();
1490 requestReferences.setInstanceId("1882939");
1491 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1492 expectedResponse.setRequestReferences(requestReferences);
1493 uri = servInstanceuri + "v7"
1494 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1495 ResponseEntity<String> response =
1496 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1497 logger.debug(response.getBody());
1499 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1500 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1501 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1505 public void createVfModuleNoModelType() throws IOException {
1506 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1507 expectedRecord.setRequestStatus("FAILED");
1508 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1509 expectedRecord.setProgress(100L);
1510 expectedRecord.setSource("VID");
1511 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1512 expectedRecord.setLastModifiedBy("APIH");
1513 expectedRecord.setVfModuleName("testVfModule2");
1514 expectedRecord.setVfModuleModelName("serviceModel");
1515 expectedRecord.setRequestScope("vfModule");
1516 expectedRecord.setRequestAction("createInstance");
1517 expectedRecord.setRequestorId("zz9999");
1518 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1519 // VnfType is not sent in this request, should be blank in db
1520 expectedRecord.setVnfType("");
1521 uri = servInstanceuri
1522 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1524 ResponseEntity<String> response =
1525 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1527 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1531 public void inPlaceSoftwareUpdate() throws IOException {
1532 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1533 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1534 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1536 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1537 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1538 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1539 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1540 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1542 // expected response
1543 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1544 RequestReferences requestReferences = new RequestReferences();
1545 requestReferences.setInstanceId("1882939");
1546 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1547 expectedResponse.setRequestReferences(requestReferences);
1548 uri = servInstanceuri + "v7"
1549 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1550 ResponseEntity<String> response =
1551 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1553 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1554 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1555 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1559 public void deleteVfModuleInstance() throws IOException {
1560 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1561 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1562 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1565 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1566 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1567 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1568 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1569 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1571 wireMockServer.stubFor(get(urlMatching(
1572 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1573 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1574 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1575 .withBody(getWiremockResponseForCatalogdb(
1576 "vnfComponentRecipeDeleteVfModule_Response.json"))
1577 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1579 // expected response
1580 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1581 RequestReferences requestReferences = new RequestReferences();
1582 requestReferences.setInstanceId("1882939");
1583 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1584 expectedResponse.setRequestReferences(requestReferences);
1585 uri = servInstanceuri + "v7"
1586 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1587 ResponseEntity<String> response =
1588 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1590 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1591 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1592 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1596 public void deleteVfModuleNoModelInvariantId() throws IOException {
1597 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1598 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1599 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1601 wireMockServer.stubFor(get(urlMatching(
1602 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1603 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1604 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1605 .withBody(getWiremockResponseForCatalogdb(
1606 "vnfComponentRecipeDeleteVfModule_Response.json"))
1607 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1609 // expected response
1610 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1611 RequestReferences requestReferences = new RequestReferences();
1612 requestReferences.setInstanceId("1882939");
1613 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1614 expectedResponse.setRequestReferences(requestReferences);
1615 uri = servInstanceuri + "v7"
1616 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1617 ResponseEntity<String> response =
1618 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1620 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1621 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1622 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1626 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1627 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1628 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1629 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1632 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1633 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1634 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1635 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1636 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1638 wireMockServer.stubFor(get(urlMatching(
1639 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1640 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1641 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1642 .withBody(getWiremockResponseForCatalogdb(
1643 "vnfComponentRecipeDeactivate_Response.json"))
1644 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1646 // expected response
1647 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1648 RequestReferences requestReferences = new RequestReferences();
1649 requestReferences.setInstanceId("1882939");
1650 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1651 expectedResponse.setRequestReferences(requestReferences);
1652 uri = servInstanceuri + "v7"
1653 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1654 ResponseEntity<String> response =
1655 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1657 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1658 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1659 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1663 public void createVolumeGroupInstance() throws IOException {
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=createInstance"))
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";
1695 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1697 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1698 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1699 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1700 assertTrue(response.getBody().contains("1882939"));
1704 public void updateVolumeGroupInstance() 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(
1710 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1711 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1712 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1713 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1715 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1717 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1718 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1720 wireMockServer.stubFor(get(urlMatching(
1721 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1722 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1723 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1724 .withBody(getWiremockResponseForCatalogdb(
1725 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1726 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1728 // expected response
1729 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1730 RequestReferences requestReferences = new RequestReferences();
1731 requestReferences.setInstanceId("1882939");
1732 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1733 expectedResponse.setRequestReferences(requestReferences);
1734 uri = servInstanceuri + "v7"
1735 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1736 ResponseEntity<String> response =
1737 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1739 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1740 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1741 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1745 public void deleteVolumeGroupInstance() throws IOException {
1746 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1747 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1748 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1750 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1751 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1752 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1754 wireMockServer.stubFor(get(urlMatching(
1755 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1756 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1757 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1758 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1760 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1761 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1762 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1763 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1765 wireMockServer.stubFor(get(urlMatching(
1766 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1767 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1768 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1769 .withBody(getWiremockResponseForCatalogdb(
1770 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1771 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1773 // expected response
1774 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1775 RequestReferences requestReferences = new RequestReferences();
1776 requestReferences.setInstanceId("1882939");
1777 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1778 expectedResponse.setRequestReferences(requestReferences);
1779 uri = servInstanceuri + "v7"
1780 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1781 ResponseEntity<String> response =
1782 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1784 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1785 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1786 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1790 public void createNetworkInstance() throws IOException {
1791 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1793 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1795 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1796 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1797 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1798 .withStatus(HttpStatus.SC_OK)));
1800 wireMockServer.stubFor(
1801 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1802 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1803 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1804 .withStatus(HttpStatus.SC_OK)));
1806 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1807 + "modelName=GR-API-DEFAULT&action=createInstance"))
1808 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1809 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1810 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1812 // expected response
1813 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1814 RequestReferences requestReferences = new RequestReferences();
1815 requestReferences.setInstanceId("1882939");
1816 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1817 expectedResponse.setRequestReferences(requestReferences);
1818 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1819 ResponseEntity<String> response =
1820 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1822 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1823 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1824 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1828 public void updateNetworkInstance() throws IOException {
1829 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1830 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1831 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1833 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1834 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1835 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1836 .withStatus(HttpStatus.SC_OK)));
1838 wireMockServer.stubFor(
1839 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1840 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1841 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1842 .withStatus(HttpStatus.SC_OK)));
1844 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1845 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1846 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1847 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1848 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1849 // expected response
1850 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1851 RequestReferences requestReferences = new RequestReferences();
1852 requestReferences.setInstanceId("1882939");
1853 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1854 expectedResponse.setRequestReferences(requestReferences);
1855 uri = servInstanceuri + "v7"
1856 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1857 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1859 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1860 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1861 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1862 assertTrue(response.getBody().contains("1882939"));
1866 public void deleteNetworkInstance() throws IOException {
1867 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1868 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1869 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1871 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1872 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1873 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1874 .withStatus(HttpStatus.SC_OK)));
1876 wireMockServer.stubFor(
1877 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1878 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1879 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1880 .withStatus(HttpStatus.SC_OK)));
1882 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1883 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1884 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1885 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1886 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1888 // expected response
1889 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1890 RequestReferences requestReferences = new RequestReferences();
1891 requestReferences.setInstanceId("1882939");
1892 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1893 expectedResponse.setRequestReferences(requestReferences);
1894 uri = servInstanceuri + "v7"
1895 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1896 ResponseEntity<String> response =
1897 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1899 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1900 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1901 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1905 public void deleteNetworkInstanceNoReqParams() throws IOException {
1906 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1907 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1908 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1910 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1911 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1912 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1913 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1914 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1917 // expected response
1918 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1919 RequestReferences requestReferences = new RequestReferences();
1920 requestReferences.setInstanceId("1882939");
1921 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1922 expectedResponse.setRequestReferences(requestReferences);
1923 uri = servInstanceuri + "v6"
1924 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1925 ResponseEntity<String> response =
1926 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1928 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1929 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1930 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1934 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1936 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1937 expectedRecord.setRequestStatus("FAILED");
1938 expectedRecord.setStatusMessage("Error mapping request: ");
1939 expectedRecord.setProgress(100L);
1940 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1941 expectedRecord.setLastModifiedBy("APIH");
1942 expectedRecord.setRequestScope("network");
1943 expectedRecord.setRequestAction("deleteInstance");
1944 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1946 uri = servInstanceuri + "v6"
1947 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1948 ResponseEntity<String> response =
1949 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1953 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1957 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1958 uri = servInstanceuri + "v5"
1959 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1960 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1962 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1966 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1967 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1968 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1969 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1971 ServiceRecipe serviceRecipe = new ServiceRecipe();
1972 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1973 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1974 serviceRecipe.setAction(Action.createInstance.toString());
1975 serviceRecipe.setId(1);
1976 serviceRecipe.setRecipeTimeout(180);
1977 Service defaultService = new Service();
1978 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1980 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1981 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1982 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1984 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1985 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1986 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1988 uri = servInstanceuri + "v7" + "/serviceInstances";
1989 ResponseEntity<String> response =
1990 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1992 // expected response
1993 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1994 RequestReferences requestReferences = new RequestReferences();
1995 requestReferences.setInstanceId("1882939");
1996 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1997 expectedResponse.setRequestReferences(requestReferences);
1999 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2000 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2001 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2005 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
2006 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2007 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2008 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2010 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2011 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2012 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2013 .withStatus(HttpStatus.SC_OK)));
2015 wireMockServer.stubFor(
2016 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2017 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2018 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2019 .withStatus(HttpStatus.SC_OK)));
2021 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2022 + "modelName=GR-API-DEFAULT&action=createInstance"))
2023 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2024 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2025 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2027 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2028 ResponseEntity<String> response =
2029 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
2031 // expected response
2032 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2033 RequestReferences requestReferences = new RequestReferences();
2034 requestReferences.setInstanceId("1882939");
2035 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2036 expectedResponse.setRequestReferences(requestReferences);
2038 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2039 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2040 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2044 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
2045 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2046 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2047 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2049 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2050 ResponseEntity<String> response =
2051 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
2053 // expected response
2054 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2055 RequestReferences requestReferences = new RequestReferences();
2056 requestReferences.setInstanceId("1882939");
2057 expectedResponse.setRequestReferences(requestReferences);
2059 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2063 public void createNetworkInstanceTestApiGrApi() throws IOException {
2064 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2065 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2066 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2068 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2069 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2070 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2071 .withStatus(HttpStatus.SC_OK)));
2073 wireMockServer.stubFor(
2074 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2076 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2077 .withStatus(HttpStatus.SC_OK)));
2079 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2080 + "modelName=GR-API-DEFAULT&action=createInstance"))
2081 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2082 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2083 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2085 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2086 ResponseEntity<String> response =
2087 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2089 // expected response
2090 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2091 RequestReferences requestReferences = new RequestReferences();
2092 requestReferences.setInstanceId("1882939");
2093 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2094 expectedResponse.setRequestReferences(requestReferences);
2096 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2097 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2098 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2102 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2103 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2104 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2105 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2107 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2108 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2109 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2110 .withStatus(HttpStatus.SC_OK)));
2112 wireMockServer.stubFor(
2113 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2114 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2115 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2116 .withStatus(HttpStatus.SC_OK)));
2118 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2119 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2120 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2121 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2122 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2124 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2125 ResponseEntity<String> response =
2126 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2128 // expected response
2129 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2130 RequestReferences requestReferences = new RequestReferences();
2131 requestReferences.setInstanceId("1882939");
2132 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2133 expectedResponse.setRequestReferences(requestReferences);
2135 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2136 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2137 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2141 public void activateServiceInstanceRequestStatus() 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/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2155 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2156 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2157 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2159 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2160 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2161 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2164 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2165 RequestReferences requestReferences = new RequestReferences();
2166 requestReferences.setInstanceId("1882939");
2167 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2168 expectedResponse.setRequestReferences(requestReferences);
2169 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2170 ResponseEntity<String> response =
2171 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2173 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2174 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2175 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2179 public void invalidRequestId() throws IOException {
2180 String illegalRequestId = "1234";
2181 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2182 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2183 uri = servInstanceuri + "v5/serviceInstances";
2184 ResponseEntity<String> response =
2185 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2187 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2188 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2192 public void invalidBPELResponse() throws IOException {
2194 ServiceRecipe serviceRecipe = new ServiceRecipe();
2195 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2196 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2197 serviceRecipe.setAction(Action.createInstance.toString());
2198 serviceRecipe.setId(1);
2199 serviceRecipe.setRecipeTimeout(180);
2200 Service defaultService = new Service();
2201 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2203 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2204 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2205 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2207 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2208 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2209 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2211 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2212 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2213 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2215 uri = servInstanceuri + "v5/serviceInstances";
2216 ResponseEntity<String> response =
2217 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2219 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2220 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2221 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2222 realResponse.getServiceException().getText());
2226 public void unauthorizedBPELResponse() throws IOException {
2228 ServiceRecipe serviceRecipe = new ServiceRecipe();
2229 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2230 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2231 serviceRecipe.setAction(Action.createInstance.toString());
2232 serviceRecipe.setId(1);
2233 serviceRecipe.setRecipeTimeout(180);
2234 Service defaultService = new Service();
2235 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2237 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2239 .withBodyFile("Camunda/UnauthorizedResponse.json")
2240 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2242 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2244 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2246 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2247 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2248 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2250 uri = servInstanceuri + "v5/serviceInstances";
2251 ResponseEntity<String> response =
2252 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2254 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2255 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2256 assertEquals("Exception caught mapping Camunda JSON response to object",
2257 realResponse.getServiceException().getText());
2261 public void invalidBPELResponse2() throws IOException {
2263 ServiceRecipe serviceRecipe = new ServiceRecipe();
2264 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2265 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2266 serviceRecipe.setAction(Action.createInstance.toString());
2267 serviceRecipe.setId(1);
2268 serviceRecipe.setRecipeTimeout(180);
2269 Service defaultService = new Service();
2270 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2272 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2273 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2274 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2276 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2277 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2278 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2280 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2281 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2282 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2283 uri = servInstanceuri + "v5/serviceInstances";
2284 ResponseEntity<String> response =
2285 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2287 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2288 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2289 assertTrue(realResponse.getServiceException().getText()
2290 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2294 public void createMacroServiceInstance() throws IOException {
2295 ServiceRecipe serviceRecipe = new ServiceRecipe();
2296 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2297 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2298 serviceRecipe.setAction(Action.createInstance.toString());
2299 serviceRecipe.setId(1);
2300 serviceRecipe.setRecipeTimeout(180);
2301 Service defaultService = new Service();
2302 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2304 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2305 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2306 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2308 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2309 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2310 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2312 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2313 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2314 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2316 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2317 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2318 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2321 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2322 RequestReferences requestReferences = new RequestReferences();
2323 requestReferences.setInstanceId("1882939");
2324 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2325 expectedResponse.setRequestReferences(requestReferences);
2326 uri = servInstanceuri + "v5";
2327 ResponseEntity<String> response =
2328 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2331 assertEquals(404, response.getStatusCode().value());
2335 public void testUserParams() throws IOException {
2336 ObjectMapper mapper = new ObjectMapper();
2337 ServiceInstancesRequest request =
2338 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2339 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2340 String userParamsTxt = inputStream("/userParams.txt");
2342 List<Map<String, Object>> userParams = requestHandlerUtils.configureUserParams(requestParameters);
2343 System.out.println(userParams);
2344 assertTrue(userParams.size() > 0);
2345 assertTrue(userParams.get(0).containsKey("name"));
2346 assertTrue(userParams.get(0).containsKey("value"));
2347 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2351 public void testConfigureCloudConfig() throws IOException {
2352 ObjectMapper mapper = new ObjectMapper();
2353 ServiceInstancesRequest request =
2354 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2355 CloudConfiguration cloudConfig =
2356 requestHandlerUtils.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2358 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2359 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2363 public void testMapToLegacyRequest() throws IOException {
2364 ObjectMapper mapper = new ObjectMapper();
2365 ServiceInstancesRequest request =
2366 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2367 ServiceInstancesRequest expected =
2368 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2369 requestHandlerUtils.mapToLegacyRequest(request.getRequestDetails());
2370 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2371 assertThat(request, sameBeanAs(expected));
2375 public void scaleOutVfModule() throws IOException {
2376 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2377 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2378 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2380 wireMockServer.stubFor(get(urlMatching(
2381 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2382 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2383 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2384 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2386 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2387 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2388 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2389 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2391 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2392 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2393 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2394 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2397 wireMockServer.stubFor(get(urlMatching(
2398 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2399 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2400 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2401 .withBody(getWiremockResponseForCatalogdb(
2402 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2403 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2405 wireMockServer.stubFor(get(urlMatching(
2406 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2407 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2408 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2409 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2411 // expected response
2412 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2413 RequestReferences requestReferences = new RequestReferences();
2414 requestReferences.setInstanceId("1882939");
2415 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2416 expectedResponse.setRequestReferences(requestReferences);
2417 uri = servInstanceuri + "v7"
2418 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2419 ResponseEntity<String> response =
2420 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2422 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2423 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2424 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2425 assertTrue(response.getBody().contains("1882939"));
2429 public void createServiceInstanceBadResponse() throws IOException {
2430 ServiceRecipe serviceRecipe = new ServiceRecipe();
2431 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2432 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2433 serviceRecipe.setAction(Action.createInstance.toString());
2434 serviceRecipe.setId(1);
2435 serviceRecipe.setRecipeTimeout(180);
2436 Service defaultService = new Service();
2437 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2439 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2440 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2441 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2443 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2445 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2447 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2448 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2449 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2451 uri = servInstanceuri + "v5/serviceInstances";
2452 ResponseEntity<String> response =
2453 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2455 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2456 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2457 assertEquals("Exception caught mapping Camunda JSON response to object",
2458 realResponse.getServiceException().getText());
2462 public void createServiceInstanceDuplicateError() throws IOException {
2463 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2464 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2465 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2467 uri = servInstanceuri + "v5/serviceInstances";
2468 ResponseEntity<String> response =
2469 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2471 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2472 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2474 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2475 realResponse.getServiceException().getText());
2479 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2480 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2481 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2482 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2483 .withStatus(HttpStatus.SC_ACCEPTED)));
2484 wireMockServer.stubFor(get(
2485 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2487 .withBodyFile("Camunda/HistoryCheckResponse.json")
2488 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2490 uri = servInstanceuri + "v5/serviceInstances";
2491 ResponseEntity<String> response =
2492 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2494 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2495 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2497 "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.",
2498 realResponse.getServiceException().getText());
2502 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2503 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2504 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2505 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2506 .withStatus(HttpStatus.SC_ACCEPTED)));
2507 wireMockServer.stubFor(get(
2508 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2509 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2510 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2512 uri = servInstanceuri + "v5/serviceInstances";
2513 ResponseEntity<String> response =
2514 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2516 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2517 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2519 "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2520 realResponse.getServiceException().getText());
2524 public void createServiceInstanceDuplicate() throws IOException {
2525 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2526 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2527 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2529 uri = servInstanceuri + "v5/serviceInstances";
2530 ResponseEntity<String> response =
2531 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2533 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2534 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2536 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2537 realResponse.getServiceException().getText());
2541 public void createServiceInstanceSaveError() throws IOException {
2542 ServiceRecipe serviceRecipe = new ServiceRecipe();
2543 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2544 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2545 serviceRecipe.setAction(Action.createInstance.toString());
2546 serviceRecipe.setId(1);
2547 serviceRecipe.setRecipeTimeout(180);
2548 Service defaultService = new Service();
2549 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2550 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2551 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2552 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2553 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2554 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2555 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2557 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2558 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2559 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2561 uri = servInstanceuri + "v5/serviceInstances";
2562 ResponseEntity<String> response =
2563 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2565 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2566 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2568 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2569 realResponse.getServiceException().getText());
2573 public void createPortConfigurationSaveError() throws IOException {
2574 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2575 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2576 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2577 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2578 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2579 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2581 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2582 ResponseEntity<String> response =
2583 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2585 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2586 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2588 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2589 realResponse.getServiceException().getText());
2593 public void createPortConfigDbUpdateError() throws IOException {
2594 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2596 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2598 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2599 ResponseEntity<String> response =
2600 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2602 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2603 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2605 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2606 realResponse.getServiceException().getText());
2610 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2611 TestAppender.events.clear();
2612 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2613 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2614 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2616 wireMockServer.stubFor(get(urlMatching(
2617 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2618 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2619 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2620 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2622 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2623 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2624 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2625 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2627 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2628 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2629 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2630 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2631 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2632 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2634 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2635 RequestReferences requestReferences = new RequestReferences();
2636 requestReferences.setInstanceId("1882939");
2637 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2638 expectedResponse.setRequestReferences(requestReferences);
2639 uri = servInstanceuri
2640 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2641 ResponseEntity<String> response =
2642 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2644 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2645 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2646 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2647 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2649 for (ILoggingEvent logEvent : TestAppender.events) {
2650 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter")
2651 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
2652 Map<String, String> mdc = logEvent.getMDCPropertyMap();
2653 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2654 assertEquals("VID", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
2660 public void createInstanceGroup() throws IOException {
2661 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2662 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2663 .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";
2672 ResponseEntity<String> response =
2673 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2676 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2677 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2678 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2682 public void deleteInstanceGroup() throws IOException {
2683 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2684 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2685 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2688 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2689 RequestReferences requestReferences = new RequestReferences();
2690 requestReferences.setInstanceId("1882939");
2691 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2692 expectedResponse.setRequestReferences(requestReferences);
2693 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2694 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2697 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2698 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2699 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2703 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2704 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2705 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2707 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2708 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2709 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2713 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2714 HttpHeaders noPartnerHeaders = new HttpHeaders();
2715 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2716 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2717 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2718 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2720 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2721 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2722 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2726 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2727 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2728 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2729 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2731 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2732 RequestReferences requestReferences = new RequestReferences();
2733 requestReferences.setInstanceId("1882939");
2734 expectedResponse.setRequestReferences(requestReferences);
2735 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2736 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2739 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2740 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2741 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2745 public void addMembers() throws IOException {
2746 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2747 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2748 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2750 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2751 RequestReferences requestReferences = new RequestReferences();
2752 requestReferences.setInstanceId("1882939");
2753 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2754 expectedResponse.setRequestReferences(requestReferences);
2755 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2756 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2759 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2760 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2761 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2765 public void removeMembers() throws IOException {
2766 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2767 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2768 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2770 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2771 RequestReferences requestReferences = new RequestReferences();
2772 requestReferences.setInstanceId("1882939");
2773 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2774 expectedResponse.setRequestReferences(requestReferences);
2775 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2776 ResponseEntity<String> response =
2777 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2780 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2781 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2782 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2786 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2787 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2788 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2789 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2791 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2793 .withStatus(HttpStatus.SC_NOT_FOUND)));
2795 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2796 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2797 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2798 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2799 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2801 // expected response
2802 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2803 RequestReferences requestReferences = new RequestReferences();
2804 requestReferences.setInstanceId("1882939");
2805 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2806 expectedResponse.setRequestReferences(requestReferences);
2807 uri = servInstanceuri + "v7"
2808 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2809 ResponseEntity<String> response =
2810 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2812 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2813 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2814 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2818 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2819 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2820 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2821 .withStatus(HttpStatus.SC_NOT_FOUND)));
2823 uri = servInstanceuri + "v7"
2824 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2825 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2827 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2828 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2829 assertEquals(realResponse.getServiceException().getText(),
2830 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2834 public void setServiceTypeTestALaCarte() throws JsonProcessingException {
2835 String requestScope = ModelType.service.toString();
2836 Boolean aLaCarteFlag = true;
2837 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2838 RequestDetails requestDetails = new RequestDetails();
2839 RequestInfo requestInfo = new RequestInfo();
2840 requestInfo.setSource("VID");
2841 requestDetails.setRequestInfo(requestInfo);
2842 sir.setRequestDetails(requestDetails);
2843 Service defaultService = new Service();
2844 defaultService.setServiceType("testServiceTypeALaCarte");
2846 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2847 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2848 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2850 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2851 assertEquals(serviceType, "testServiceTypeALaCarte");
2855 public void setServiceTypeTest() throws JsonProcessingException {
2856 String requestScope = ModelType.service.toString();
2857 Boolean aLaCarteFlag = false;
2858 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2859 RequestDetails requestDetails = new RequestDetails();
2860 RequestInfo requestInfo = new RequestInfo();
2861 ModelInfo modelInfo = new ModelInfo();
2862 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2863 requestInfo.setSource("VID");
2864 requestDetails.setModelInfo(modelInfo);
2865 requestDetails.setRequestInfo(requestInfo);
2866 sir.setRequestDetails(requestDetails);
2867 Service defaultService = new Service();
2868 defaultService.setServiceType("testServiceType");
2870 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2871 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2872 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2874 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2875 assertEquals(serviceType, "testServiceType");
2879 public void setServiceTypeTestDefault() throws JsonProcessingException {
2880 String requestScope = ModelType.service.toString();
2881 Boolean aLaCarteFlag = false;
2882 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2883 RequestDetails requestDetails = new RequestDetails();
2884 RequestInfo requestInfo = new RequestInfo();
2885 ModelInfo modelInfo = new ModelInfo();
2886 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2887 requestInfo.setSource("VID");
2888 requestDetails.setModelInfo(modelInfo);
2889 requestDetails.setRequestInfo(requestInfo);
2890 sir.setRequestDetails(requestDetails);
2891 Service defaultService = new Service();
2892 defaultService.setServiceType("testServiceType");
2894 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2895 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2896 .withStatus(HttpStatus.SC_NOT_FOUND)));
2897 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2898 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2899 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2901 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2902 assertEquals(serviceType, "testServiceType");
2906 public void setServiceTypeTestNetwork() throws JsonProcessingException {
2907 String requestScope = ModelType.network.toString();
2908 Boolean aLaCarteFlag = null;
2909 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2910 RequestDetails requestDetails = new RequestDetails();
2911 RequestInfo requestInfo = new RequestInfo();
2912 ModelInfo modelInfo = new ModelInfo();
2913 modelInfo.setModelName("networkModelName");
2914 requestInfo.setSource("VID");
2915 requestDetails.setModelInfo(modelInfo);
2916 requestDetails.setRequestInfo(requestInfo);
2917 sir.setRequestDetails(requestDetails);
2919 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2920 assertEquals(serviceType, "networkModelName");
2924 public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
2925 String requestScope = "instanceGroup";
2926 ServiceInstancesRequest sir =
2927 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
2928 assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
2929 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2933 public void setServiceInstanceIdTest() {
2934 String requestScope = "vnf";
2935 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2936 sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2937 assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
2938 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2942 public void setServiceInstanceIdReturnNullTest() {
2943 String requestScope = "vnf";
2944 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2945 assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2949 public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
2950 wireMockServer.stubFor(get(
2951 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2952 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2953 .withBodyFile("Camunda/HistoryCheckResponse.json")
2954 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2956 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2957 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2958 boolean inProgress = false;
2959 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2960 assertTrue(inProgress);
2964 public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
2965 wireMockServer.stubFor(get(
2966 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2967 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2968 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
2970 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2971 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2972 boolean inProgress = false;
2973 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2974 assertFalse(inProgress);
2978 public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException {
2979 wireMockServer.stubFor(get(
2980 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2981 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2982 .withBodyFile("Camunda/HistoryCheckResponseCompleted.json")
2983 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2985 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2986 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2987 boolean inProgress = false;
2988 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2989 assertFalse(inProgress);
2993 public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
2994 String replaceVfModule = inputStream("/ReplaceVfModule.json");
2995 ObjectMapper mapper = new ObjectMapper();
2996 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2997 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2998 assertEquals(Action.replaceInstance, action);
3002 public void handleReplaceInstance_retainAssignments_Test()
3003 throws JsonParseException, JsonMappingException, IOException {
3004 String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
3005 ObjectMapper mapper = new ObjectMapper();
3006 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
3007 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
3008 assertEquals(Action.replaceInstanceRetainAssignments, action);
3012 public void getCloudConfigurationAAIEntityNotFoundTest() throws IOException {
3013 RequestError expectedResponse =
3014 mapper.readValue(inputStream("/AAIEntityNotFoundResponse.json"), RequestError.class);
3015 uri = servInstanceuri + "v7"
3016 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
3017 ResponseEntity<String> response =
3018 sendRequest(inputStream("/ReplaceVfModuleNoCloudConfig.json"), uri, HttpMethod.POST, headers);
3020 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
3021 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
3022 assertThat(expectedResponse, sameBeanAs(realResponse));