2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.apihandlerinfra;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
29 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertFalse;
32 import static org.junit.Assert.assertNotNull;
33 import static org.junit.Assert.assertNull;
34 import static org.junit.Assert.assertThat;
35 import static org.junit.Assert.assertTrue;
36 import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
37 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
38 import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
39 import static org.onap.so.logger.MdcConstants.CLIENT_ID;
40 import static org.onap.so.logger.MdcConstants.ENDTIME;
41 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
42 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
43 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
44 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
45 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
46 import static org.onap.so.logger.MdcConstants.STATUSCODE;
48 import java.io.IOException;
49 import java.net.MalformedURLException;
51 import java.nio.file.Files;
52 import java.nio.file.Paths;
53 import java.util.List;
55 import javax.ws.rs.core.MediaType;
56 import javax.ws.rs.core.Response;
57 import org.apache.http.HttpStatus;
58 import org.junit.Before;
59 import org.junit.Test;
60 import org.mockito.Mockito;
61 import org.onap.logging.ref.slf4j.ONAPLogConstants;
62 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
63 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
64 import org.onap.so.db.catalog.beans.Service;
65 import org.onap.so.db.catalog.beans.ServiceRecipe;
66 import org.onap.so.db.request.beans.InfraActiveRequests;
67 import org.onap.so.logger.HttpHeadersConstants;
68 import org.onap.so.serviceinstancebeans.CloudConfiguration;
69 import org.onap.so.serviceinstancebeans.ModelInfo;
70 import org.onap.so.serviceinstancebeans.ModelType;
71 import org.onap.so.serviceinstancebeans.RequestDetails;
72 import org.onap.so.serviceinstancebeans.RequestError;
73 import org.onap.so.serviceinstancebeans.RequestInfo;
74 import org.onap.so.serviceinstancebeans.RequestParameters;
75 import org.onap.so.serviceinstancebeans.RequestReferences;
76 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
77 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
78 import org.springframework.beans.factory.annotation.Autowired;
79 import org.springframework.beans.factory.annotation.Value;
80 import org.springframework.http.HttpEntity;
81 import org.springframework.http.HttpHeaders;
82 import org.springframework.http.HttpMethod;
83 import org.springframework.http.ResponseEntity;
84 import org.springframework.util.ResourceUtils;
85 import org.springframework.web.util.UriComponentsBuilder;
86 import com.fasterxml.jackson.core.JsonParseException;
87 import com.fasterxml.jackson.core.JsonProcessingException;
88 import com.fasterxml.jackson.databind.DeserializationFeature;
89 import com.fasterxml.jackson.databind.JsonMappingException;
90 import com.fasterxml.jackson.databind.ObjectMapper;
91 import com.github.tomakehurst.wiremock.http.Fault;
92 import ch.qos.logback.classic.spi.ILoggingEvent;
94 public class ServiceInstancesTest extends BaseTest {
96 private final ObjectMapper mapper = new ObjectMapper();
97 private ObjectMapper errorMapper = new ObjectMapper();
100 private ServiceInstances servInstances;
103 private RequestHandlerUtils requestHandlerUtils;
105 @Value("${wiremock.server.port}")
106 private String wiremockPort;
108 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
109 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
111 private URL selfLink;
112 private URL initialUrl;
113 private int initialPort;
114 private HttpHeaders headers;
117 public void beforeClass() {
118 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
119 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
120 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
122 headers = new HttpHeaders();
123 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
124 headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
125 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
126 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
127 headers.set(CLIENT_ID, "VID");
128 headers.set(REQUESTOR_ID, "xxxxxx");
129 try { // generate one-time port number to avoid RANDOM port number later.
130 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
131 initialPort = initialUrl.getPort();
132 } catch (MalformedURLException e) {
135 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*")).willReturn(aResponse()
136 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
137 Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
140 public String inputStream(String JsonInput) throws IOException {
141 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
142 return new String(Files.readAllBytes(Paths.get(JsonInput)));
145 private URL createExpectedSelfLink(String version, String requestId) {
146 System.out.println("createdUrl: " + initialUrl.toString());
148 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
149 } catch (MalformedURLException e) {
155 private String getWiremockResponseForCatalogdb(String file) {
157 File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
158 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
159 "localhost:" + wiremockPort);
160 } catch (IOException e) {
167 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
168 HttpHeaders headers) {
170 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
171 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
173 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
174 headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
177 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
179 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
181 return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
184 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
185 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
189 public void createServiceInstanceVIDDefault() throws IOException {
190 TestAppender.events.clear();
192 ServiceRecipe serviceRecipe = new ServiceRecipe();
193 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
194 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
195 serviceRecipe.setAction(Action.createInstance.toString());
196 serviceRecipe.setId(1);
197 serviceRecipe.setRecipeTimeout(180);
198 Service defaultService = new Service();
199 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
202 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
204 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
206 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
207 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
208 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
210 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
211 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
212 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
215 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
216 RequestReferences requestReferences = new RequestReferences();
217 requestReferences.setInstanceId("1882939");
218 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
219 expectedResponse.setRequestReferences(requestReferences);
220 uri = servInstanceuri + "v5/serviceInstances";
221 ResponseEntity<String> response =
222 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
225 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
226 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
227 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
231 for (ILoggingEvent logEvent : TestAppender.events)
232 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
233 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
234 Map<String, String> mdc = logEvent.getMDCPropertyMap();
235 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
236 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
237 assertNotNull(mdc.get(INVOCATION_ID));
238 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
239 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
240 assertEquals("INPROGRESS", mdc.get(STATUSCODE));
241 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging")
242 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
243 Map<String, String> mdc = logEvent.getMDCPropertyMap();
244 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
245 assertNotNull(mdc.get(ENDTIME));
246 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
247 assertNotNull(mdc.get(INVOCATION_ID));
248 assertEquals("202", mdc.get(RESPONSECODE));
249 assertEquals("UNKNOWN", mdc.get(PARTNERNAME));
250 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances", mdc.get(SERVICE_NAME));
251 assertEquals("COMPLETE", mdc.get(STATUSCODE));
252 assertNotNull(mdc.get(RESPONSEDESC));
253 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
254 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
255 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
260 public void createServiceInstanceServiceInstancesUri() throws IOException {
261 ServiceRecipe serviceRecipe = new ServiceRecipe();
262 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
263 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
264 serviceRecipe.setAction(Action.createInstance.toString());
265 serviceRecipe.setId(1);
266 serviceRecipe.setRecipeTimeout(180);
267 Service defaultService = new Service();
268 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
270 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
272 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
275 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
276 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
277 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
279 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
280 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
281 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
283 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
284 RequestReferences requestReferences = new RequestReferences();
285 requestReferences.setInstanceId("1882939");
286 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
287 expectedResponse.setRequestReferences(requestReferences);
288 uri = servInstanceUriPrev7 + "v5";
289 ResponseEntity<String> response =
290 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
293 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
294 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
295 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
299 public void createServiceInstanceBpelStatusError() throws IOException {
300 ServiceRecipe serviceRecipe = new ServiceRecipe();
301 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
302 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
303 serviceRecipe.setAction(Action.createInstance.toString());
304 serviceRecipe.setId(1);
305 serviceRecipe.setRecipeTimeout(180);
306 Service defaultService = new Service();
307 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
310 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
311 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
312 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
315 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
316 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
317 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
319 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
321 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
323 uri = servInstanceuri + "v5/serviceInstances";
324 ResponseEntity<String> response =
325 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
327 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
331 public void createServiceInstanceBadGateway() throws IOException {
332 ServiceRecipe serviceRecipe = new ServiceRecipe();
333 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
334 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
335 serviceRecipe.setAction(Action.createInstance.toString());
336 serviceRecipe.setId(1);
337 serviceRecipe.setRecipeTimeout(180);
338 Service defaultService = new Service();
339 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
341 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
342 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
344 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
345 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
346 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
348 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
349 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
350 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
352 uri = servInstanceuri + "v5/serviceInstances";
353 ResponseEntity<String> response =
354 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
356 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
360 public void createServiceInstanceEmptyResponse() throws IOException {
361 ServiceRecipe serviceRecipe = new ServiceRecipe();
362 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
363 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
364 serviceRecipe.setAction(Action.createInstance.toString());
365 serviceRecipe.setId(1);
366 serviceRecipe.setRecipeTimeout(180);
367 Service defaultService = new Service();
368 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
370 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
371 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
373 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
374 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
375 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
377 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
378 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
379 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
381 uri = servInstanceuri + "v5/serviceInstances";
382 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
384 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
388 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
389 TestAppender.events.clear();
390 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
391 HttpHeaders requestIDheaders = new HttpHeaders();
392 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
393 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
394 HttpMethod.POST, requestIDheaders);
396 Service defaultService = new Service();
397 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
399 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
400 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
401 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
404 wireMockServer.stubFor(get(urlMatching(
405 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
406 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
407 .withStatus(HttpStatus.SC_NOT_FOUND)));
409 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
413 public void activateServiceInstanceNoRecipe() throws IOException {
414 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
415 Service defaultService = new Service();
416 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
417 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
418 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
419 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
421 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
422 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
424 ResponseEntity<String> response =
425 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
427 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
431 public void activateServiceInstance() throws IOException {
432 ServiceRecipe serviceRecipe = new ServiceRecipe();
433 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
434 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
435 serviceRecipe.setAction(Action.createInstance.toString());
436 serviceRecipe.setId(1);
437 serviceRecipe.setRecipeTimeout(180);
438 Service defaultService = new Service();
439 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
441 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
442 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
443 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
445 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
446 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
447 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
449 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
450 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
451 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
453 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
454 RequestReferences requestReferences = new RequestReferences();
455 requestReferences.setInstanceId("1882939");
456 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
457 expectedResponse.setRequestReferences(requestReferences);
458 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
459 ResponseEntity<String> response =
460 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
462 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
463 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
464 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
468 public void deactivateServiceInstance() throws IOException {
470 ServiceRecipe serviceRecipe = new ServiceRecipe();
471 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
472 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
473 serviceRecipe.setAction(Action.createInstance.toString());
474 serviceRecipe.setId(1);
475 serviceRecipe.setRecipeTimeout(180);
476 Service defaultService = new Service();
477 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
479 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
480 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
481 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
483 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
484 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
485 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
487 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
488 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
489 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
491 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
492 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
493 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
496 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
497 RequestReferences requestReferences = new RequestReferences();
498 requestReferences.setInstanceId("1882939");
499 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
500 expectedResponse.setRequestReferences(requestReferences);
501 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
502 ResponseEntity<String> response =
503 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
505 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
506 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
507 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
511 public void deleteServiceInstance() throws IOException {
512 ServiceRecipe serviceRecipe = new ServiceRecipe();
513 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
514 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
515 serviceRecipe.setAction(Action.createInstance.toString());
516 serviceRecipe.setId(1);
517 serviceRecipe.setRecipeTimeout(180);
518 Service defaultService = new Service();
519 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
521 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
522 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
523 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
525 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
526 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
527 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
529 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
530 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
531 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
533 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
534 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
535 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
537 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
538 RequestReferences requestReferences = new RequestReferences();
539 requestReferences.setInstanceId("1882939");
540 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
541 expectedResponse.setRequestReferences(requestReferences);
542 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
543 ResponseEntity<String> response =
544 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
546 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
547 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
548 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
552 public void assignServiceInstance() throws IOException {
553 ServiceRecipe serviceRecipe = new ServiceRecipe();
554 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
555 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
556 serviceRecipe.setAction(Action.createInstance.toString());
557 serviceRecipe.setId(1);
558 serviceRecipe.setRecipeTimeout(180);
559 Service defaultService = new Service();
560 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
562 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
563 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
564 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
566 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
567 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
568 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
570 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
571 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
572 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
574 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
575 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
576 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
578 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
579 RequestReferences requestReferences = new RequestReferences();
580 requestReferences.setInstanceId("1882939");
581 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
582 expectedResponse.setRequestReferences(requestReferences);
583 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
584 ResponseEntity<String> response =
585 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
587 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
588 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
589 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
593 public void unassignServiceInstance() throws IOException {
594 ServiceRecipe serviceRecipe = new ServiceRecipe();
595 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
596 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
597 serviceRecipe.setAction(Action.createInstance.toString());
598 serviceRecipe.setId(1);
599 serviceRecipe.setRecipeTimeout(180);
600 Service defaultService = new Service();
601 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
603 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
604 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
605 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
607 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
608 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
609 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
611 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
612 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
613 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
615 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
616 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
617 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
619 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
620 RequestReferences requestReferences = new RequestReferences();
621 requestReferences.setInstanceId("1882939");
622 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
623 expectedResponse.setRequestReferences(requestReferences);
624 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
625 ResponseEntity<String> response =
626 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
628 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
629 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
630 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
634 public void createPortConfiguration() throws IOException {
635 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
636 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
637 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
639 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
640 RequestReferences requestReferences = new RequestReferences();
641 requestReferences.setInstanceId("1882939");
642 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
643 expectedResponse.setRequestReferences(requestReferences);
644 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
645 ResponseEntity<String> response =
646 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
648 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
649 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
650 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
651 assertTrue(response.getBody().contains("1882939"));
655 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
656 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
657 ResponseEntity<String> response =
658 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
660 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
664 public void deletePortConfiguration() throws IOException {
665 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
666 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
667 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
670 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
671 RequestReferences requestReferences = new RequestReferences();
672 requestReferences.setInstanceId("1882939");
673 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
674 expectedResponse.setRequestReferences(requestReferences);
675 uri = servInstanceuri + "v7"
676 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
677 ResponseEntity<String> response =
678 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
680 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
681 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
682 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
686 public void enablePort() throws IOException {
687 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
688 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
689 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
691 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
692 RequestReferences requestReferences = new RequestReferences();
693 requestReferences.setInstanceId("1882939");
694 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
695 expectedResponse.setRequestReferences(requestReferences);
696 uri = servInstanceuri + "v7"
697 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
698 ResponseEntity<String> response =
699 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
701 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
702 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
703 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
707 public void disablePort() throws IOException {
708 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
709 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
710 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
712 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
713 RequestReferences requestReferences = new RequestReferences();
714 requestReferences.setInstanceId("1882939");
715 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
716 expectedResponse.setRequestReferences(requestReferences);
717 uri = servInstanceuri + "v7"
718 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
719 ResponseEntity<String> response =
720 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
722 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
723 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
724 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
728 public void activatePort() throws IOException {
729 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
730 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
731 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
733 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
734 RequestReferences requestReferences = new RequestReferences();
735 requestReferences.setInstanceId("1882939");
736 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
737 expectedResponse.setRequestReferences(requestReferences);
738 uri = servInstanceuri + "v7"
739 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
740 ResponseEntity<String> response =
741 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
743 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
744 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
745 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
749 public void deactivatePort() throws IOException {
750 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
751 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
752 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
754 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
755 RequestReferences requestReferences = new RequestReferences();
756 requestReferences.setInstanceId("1882939");
757 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
758 expectedResponse.setRequestReferences(requestReferences);
759 uri = servInstanceuri + "v7"
760 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
761 ResponseEntity<String> response =
762 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
764 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
765 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
766 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
770 public void addRelationships() throws IOException {
771 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
772 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
773 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
775 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
776 RequestReferences requestReferences = new RequestReferences();
777 requestReferences.setInstanceId("1882939");
778 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
779 expectedResponse.setRequestReferences(requestReferences);
780 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
781 ResponseEntity<String> response =
782 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
784 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
785 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
786 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
790 public void removeRelationships() throws IOException {
791 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
793 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
795 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
796 RequestReferences requestReferences = new RequestReferences();
797 requestReferences.setInstanceId("1882939");
798 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
799 expectedResponse.setRequestReferences(requestReferences);
800 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
801 ResponseEntity<String> response =
802 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
804 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
805 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
806 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
810 public void createVnfInstanceNoALaCarte() throws IOException {
811 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
812 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
813 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
816 wireMockServer.stubFor(get(urlMatching(
817 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
818 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
819 .withBody(getWiremockResponseForCatalogdb(
820 "vnfResourceCustomization_ReplaceVnf_Response.json"))
821 .withStatus(org.apache.http.HttpStatus.SC_OK)));
823 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
824 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
825 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
826 .withStatus(org.apache.http.HttpStatus.SC_OK)));
828 wireMockServer.stubFor(get(urlMatching(
829 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
830 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
831 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
832 .withStatus(org.apache.http.HttpStatus.SC_OK)));
835 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
836 RequestReferences requestReferences = new RequestReferences();
837 requestReferences.setInstanceId("1882939");
838 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
839 expectedResponse.setRequestReferences(requestReferences);
840 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
841 ResponseEntity<String> response =
842 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
844 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
845 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
846 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
850 public void createVnfInstance() throws IOException {
851 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
852 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
853 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
855 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
856 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
857 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
858 .withStatus(org.apache.http.HttpStatus.SC_OK)));
859 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
860 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
861 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
862 .withStatus(org.apache.http.HttpStatus.SC_OK)));
865 wireMockServer.stubFor(
866 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
867 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
868 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
869 .withStatus(org.apache.http.HttpStatus.SC_OK)));
871 wireMockServer.stubFor(get(urlMatching(
872 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
873 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
874 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
875 .withStatus(org.apache.http.HttpStatus.SC_OK)));
878 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
879 RequestReferences requestReferences = new RequestReferences();
880 requestReferences.setInstanceId("1882939");
881 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
882 expectedResponse.setRequestReferences(requestReferences);
883 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
884 ResponseEntity<String> response =
885 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
887 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
888 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
889 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
890 assertTrue(response.getBody().contains("1882939"));
894 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
895 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
896 ResponseEntity<String> response =
897 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
899 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
903 public void createVnfInstanceInvalidVnfResource() throws IOException {
904 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
905 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
907 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
908 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
909 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
913 public void replaceVnfInstance() throws IOException {
914 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
915 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
916 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
918 wireMockServer.stubFor(get(urlMatching(
919 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
920 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
921 .withBody(getWiremockResponseForCatalogdb(
922 "vnfResourceCustomization_ReplaceVnf_Response.json"))
923 .withStatus(org.apache.http.HttpStatus.SC_OK)));
925 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
926 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
927 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
928 .withStatus(org.apache.http.HttpStatus.SC_OK)));
930 wireMockServer.stubFor(get(urlMatching(
931 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
932 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
933 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
934 .withStatus(org.apache.http.HttpStatus.SC_OK)));
936 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
937 RequestReferences requestReferences = new RequestReferences();
938 requestReferences.setInstanceId("1882939");
939 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
940 expectedResponse.setRequestReferences(requestReferences);
941 uri = servInstanceuri + "v7"
942 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
943 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
945 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
946 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
947 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
951 public void replaceVnfRecreateInstance() throws IOException {
952 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
953 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
954 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
956 wireMockServer.stubFor(get(urlMatching(
957 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
958 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
959 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
960 .withStatus(org.apache.http.HttpStatus.SC_OK)));
962 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
963 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
964 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
965 .withStatus(org.apache.http.HttpStatus.SC_OK)));
967 wireMockServer.stubFor(get(urlMatching(
968 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
969 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
970 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
971 .withStatus(org.apache.http.HttpStatus.SC_OK)));
974 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
975 RequestReferences requestReferences = new RequestReferences();
976 requestReferences.setInstanceId("1882939");
977 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
978 expectedResponse.setRequestReferences(requestReferences);
979 uri = servInstanceuri + "v7"
980 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
981 ResponseEntity<String> response =
982 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
983 logger.debug(response.getBody());
985 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
986 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
987 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
991 public void recreateVnfInstance() throws IOException {
992 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
993 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
994 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
996 wireMockServer.stubFor(get(urlMatching(
997 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
998 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
999 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
1000 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1002 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1003 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1004 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1005 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1007 wireMockServer.stubFor(get(urlMatching(
1008 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1009 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1010 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1011 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1013 // expected response
1014 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1015 RequestReferences requestReferences = new RequestReferences();
1016 requestReferences.setInstanceId("1882939");
1017 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1018 expectedResponse.setRequestReferences(requestReferences);
1019 uri = servInstanceuri + "v7"
1020 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1021 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1022 logger.debug(response.getBody());
1024 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1025 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1026 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1030 public void updateVnfInstance() throws IOException {
1031 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1032 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1033 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1035 wireMockServer.stubFor(get(urlMatching(
1036 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1037 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1038 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1039 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1041 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1042 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1043 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1044 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1046 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1047 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1048 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1049 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1050 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1052 // expected response
1053 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1054 RequestReferences requestReferences = new RequestReferences();
1055 requestReferences.setInstanceId("1882939");
1056 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1057 expectedResponse.setRequestReferences(requestReferences);
1058 uri = servInstanceuri + "v7"
1059 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1060 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
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 applyUpdatedConfig() throws IOException {
1069 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1070 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1071 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1074 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1075 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1076 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1077 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1078 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1080 // expected response
1081 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1082 RequestReferences requestReferences = new RequestReferences();
1083 requestReferences.setInstanceId("1882939");
1084 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1085 expectedResponse.setRequestReferences(requestReferences);
1086 uri = servInstanceuri + "v7"
1087 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1088 ResponseEntity<String> response =
1089 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1091 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1092 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1093 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1097 public void deleteVnfInstanceV5() throws IOException {
1098 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1099 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1100 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1102 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1103 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1104 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1105 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1106 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1107 // expected response
1108 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1109 RequestReferences requestReferences = new RequestReferences();
1110 requestReferences.setInstanceId("1882939");
1111 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1112 expectedResponse.setRequestReferences(requestReferences);
1113 uri = servInstanceuri + "v5"
1114 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1115 ResponseEntity<String> response =
1116 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1118 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1119 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1120 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1124 public void createVfModuleInstance() throws IOException {
1125 wireMockServer.stubFor(get(urlMatching(
1126 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1127 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1128 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1129 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1131 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1132 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1133 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1134 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1136 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1137 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1138 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1139 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1141 wireMockServer.stubFor(get(urlMatching(
1142 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1143 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1144 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1145 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1147 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1148 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1149 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1151 wireMockServer.stubFor(get(urlMatching(
1152 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1153 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1154 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1155 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1156 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1157 // expected response
1158 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1159 RequestReferences requestReferences = new RequestReferences();
1160 requestReferences.setInstanceId("1882939");
1161 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1162 expectedResponse.setRequestReferences(requestReferences);
1163 uri = servInstanceuri + "v7"
1164 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1165 ResponseEntity<String> response =
1166 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1168 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1169 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1170 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1171 assertTrue(response.getBody().contains("1882939"));
1175 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1176 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1177 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1178 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1180 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1181 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1182 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1183 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1186 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1187 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1188 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1189 .withBody(getWiremockResponseForCatalogdb(
1190 "vnfResourceCustomizationForVfModule_Response.json"))
1191 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1193 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1194 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1195 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1196 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1198 wireMockServer.stubFor(get(urlMatching(
1199 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1200 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1201 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1202 .withBody(getWiremockResponseForCatalogdb(
1203 "vfModuleCustomizationPCM_Response.json"))
1204 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1206 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1207 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1208 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1209 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1211 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1212 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1213 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1214 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1217 wireMockServer.stubFor(
1218 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1219 + "[?]vnfComponentType=vfModule&action=createInstance"))
1220 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1221 .withBody(getWiremockResponseForCatalogdb(
1222 "vnfComponentRecipeVNF_API_Response.json"))
1223 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1225 // expected response
1226 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1227 RequestReferences requestReferences = new RequestReferences();
1228 requestReferences.setInstanceId("1882939");
1229 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1230 expectedResponse.setRequestReferences(requestReferences);
1231 uri = servInstanceuri + "v6"
1232 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1233 ResponseEntity<String> response =
1234 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1235 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1236 ObjectMapper mapper = new ObjectMapper();
1237 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1238 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1242 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1243 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1244 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1245 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1247 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1248 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1249 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1250 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1253 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1254 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1255 .withBody(getWiremockResponseForCatalogdb(
1256 "vnfResourceCustomizationForVfModule_Response.json"))
1257 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1259 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1260 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1261 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1262 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1264 wireMockServer.stubFor(get(urlMatching(
1265 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1266 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1267 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1268 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1270 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1272 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1273 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1275 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1276 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1277 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1278 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1280 wireMockServer.stubFor(get(urlMatching(
1281 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1282 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1283 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1284 .withBody(getWiremockResponseForCatalogdb(
1285 "vnfComponentRecipeDeleteVfModule_Response.json"))
1286 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1288 // expected response
1289 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1290 RequestReferences requestReferences = new RequestReferences();
1291 requestReferences.setInstanceId("1882939");
1292 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1293 expectedResponse.setRequestReferences(requestReferences);
1294 uri = servInstanceuri + "v6"
1295 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1296 ResponseEntity<String> response =
1297 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1300 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1301 ObjectMapper mapper = new ObjectMapper();
1302 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1303 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1307 public void createVfModuleInstanceNoRecipe() throws IOException {
1309 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1310 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1311 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1312 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1315 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1316 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1317 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1318 .withBody(getWiremockResponseForCatalogdb(
1319 "vnfResourceCustomizationForVfModule_Response.json"))
1320 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1322 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1323 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1324 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1325 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1327 wireMockServer.stubFor(
1328 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1329 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1330 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1331 .withBody(getWiremockResponseForCatalogdb(
1332 "vfModuleCustomizationPCM_Response.json"))
1333 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1335 uri = servInstanceuri + "v6"
1336 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1337 ResponseEntity<String> response =
1338 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1340 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1341 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1342 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1346 public void replaceVfModuleInstance() throws IOException {
1347 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1348 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1349 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1352 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1353 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1354 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1355 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1356 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1358 wireMockServer.stubFor(get(urlMatching(
1359 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1360 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1361 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1362 .withBody(getWiremockResponseForCatalogdb(
1363 "vnfComponentRecipeDeleteVfModule_Response.json"))
1364 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1365 // expected response
1366 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1367 RequestReferences requestReferences = new RequestReferences();
1368 requestReferences.setInstanceId("1882939");
1369 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1370 expectedResponse.setRequestReferences(requestReferences);
1371 uri = servInstanceuri + "v7"
1372 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1373 ResponseEntity<String> response =
1374 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1376 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1377 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1378 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1382 public void updateVfModuleInstance() throws IOException {
1383 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1384 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1385 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1387 wireMockServer.stubFor(get(urlMatching(
1388 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1389 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1390 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1391 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1393 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1394 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1395 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1396 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1398 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1400 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1401 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1403 wireMockServer.stubFor(get(urlMatching(
1404 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1405 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1406 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1407 .withBody(getWiremockResponseForCatalogdb(
1408 "vnfComponentRecipe_GRAPI_Response.json"))
1409 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1411 // expected response
1412 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1413 RequestReferences requestReferences = new RequestReferences();
1414 requestReferences.setInstanceId("1882939");
1415 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1416 expectedResponse.setRequestReferences(requestReferences);
1417 uri = servInstanceuri + "v7"
1418 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1419 ResponseEntity<String> response =
1420 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1421 logger.debug(response.getBody());
1423 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1424 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1425 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1429 public void createVfModuleNoModelType() throws IOException {
1430 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1431 expectedRecord.setRequestStatus("FAILED");
1432 expectedRecord.setAction("createInstance");
1433 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1434 expectedRecord.setProgress(100L);
1435 expectedRecord.setSource("VID");
1436 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1437 expectedRecord.setLastModifiedBy("APIH");
1438 expectedRecord.setVfModuleName("testVfModule2");
1439 expectedRecord.setVfModuleModelName("serviceModel");
1440 expectedRecord.setRequestScope("vfModule");
1441 expectedRecord.setRequestAction("createInstance");
1442 expectedRecord.setRequestorId("zz9999");
1443 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1444 // VnfType is not sent in this request, should be blank in db
1445 expectedRecord.setVnfType("");
1446 uri = servInstanceuri
1447 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1449 ResponseEntity<String> response =
1450 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1452 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1456 public void inPlaceSoftwareUpdate() throws IOException {
1457 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1458 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1459 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1461 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1462 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1463 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1464 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1465 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1467 // expected response
1468 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1469 RequestReferences requestReferences = new RequestReferences();
1470 requestReferences.setInstanceId("1882939");
1471 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1472 expectedResponse.setRequestReferences(requestReferences);
1473 uri = servInstanceuri + "v7"
1474 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1475 ResponseEntity<String> response =
1476 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1478 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1479 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1480 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1484 public void deleteVfModuleInstance() throws IOException {
1485 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1487 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1490 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1491 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1492 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1493 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1494 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1496 wireMockServer.stubFor(get(urlMatching(
1497 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1498 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1499 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1500 .withBody(getWiremockResponseForCatalogdb(
1501 "vnfComponentRecipeDeleteVfModule_Response.json"))
1502 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1504 // expected response
1505 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1506 RequestReferences requestReferences = new RequestReferences();
1507 requestReferences.setInstanceId("1882939");
1508 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1509 expectedResponse.setRequestReferences(requestReferences);
1510 uri = servInstanceuri + "v7"
1511 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1512 ResponseEntity<String> response =
1513 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1515 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1516 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1517 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1521 public void deleteVfModuleNoModelInvariantId() throws IOException {
1522 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1523 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1524 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1526 wireMockServer.stubFor(get(urlMatching(
1527 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1528 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1530 .withBody(getWiremockResponseForCatalogdb(
1531 "vnfComponentRecipeDeleteVfModule_Response.json"))
1532 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1534 // expected response
1535 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1536 RequestReferences requestReferences = new RequestReferences();
1537 requestReferences.setInstanceId("1882939");
1538 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1539 expectedResponse.setRequestReferences(requestReferences);
1540 uri = servInstanceuri + "v7"
1541 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1542 ResponseEntity<String> response =
1543 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1545 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1546 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1547 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1551 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1552 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1553 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1554 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1557 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1558 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1559 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1560 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1561 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1563 wireMockServer.stubFor(get(urlMatching(
1564 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1565 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1566 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1567 .withBody(getWiremockResponseForCatalogdb(
1568 "vnfComponentRecipeDeactivate_Response.json"))
1569 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1571 // expected response
1572 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1573 RequestReferences requestReferences = new RequestReferences();
1574 requestReferences.setInstanceId("1882939");
1575 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1576 expectedResponse.setRequestReferences(requestReferences);
1577 uri = servInstanceuri + "v7"
1578 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1579 ResponseEntity<String> response =
1580 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1582 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1583 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1584 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1588 public void createVolumeGroupInstance() throws IOException {
1589 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1590 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1591 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1593 wireMockServer.stubFor(get(urlMatching(
1594 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1596 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1597 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1599 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1601 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1602 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1604 wireMockServer.stubFor(get(urlMatching(
1605 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1606 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1607 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1608 .withBody(getWiremockResponseForCatalogdb(
1609 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1610 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1612 // expected response
1613 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1614 RequestReferences requestReferences = new RequestReferences();
1615 requestReferences.setInstanceId("1882939");
1616 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1617 expectedResponse.setRequestReferences(requestReferences);
1618 uri = servInstanceuri + "v7"
1619 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1620 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1622 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1623 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1624 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1625 assertTrue(response.getBody().contains("1882939"));
1629 public void updateVolumeGroupInstance() throws IOException {
1630 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1631 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1632 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1634 wireMockServer.stubFor(get(urlMatching(
1635 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1636 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1637 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1638 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1640 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1641 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1642 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1643 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1645 wireMockServer.stubFor(get(urlMatching(
1646 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1647 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1648 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1649 .withBody(getWiremockResponseForCatalogdb(
1650 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1651 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1653 // expected response
1654 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1655 RequestReferences requestReferences = new RequestReferences();
1656 requestReferences.setInstanceId("1882939");
1657 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1658 expectedResponse.setRequestReferences(requestReferences);
1659 uri = servInstanceuri + "v7"
1660 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1661 ResponseEntity<String> response =
1662 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1664 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1665 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1666 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1670 public void deleteVolumeGroupInstance() throws IOException {
1671 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1672 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1673 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1675 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1676 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1677 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1679 wireMockServer.stubFor(get(urlMatching(
1680 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1681 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1682 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1683 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1685 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1686 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1687 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1688 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1690 wireMockServer.stubFor(get(urlMatching(
1691 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1692 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1693 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1694 .withBody(getWiremockResponseForCatalogdb(
1695 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1696 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1698 // expected response
1699 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1700 RequestReferences requestReferences = new RequestReferences();
1701 requestReferences.setInstanceId("1882939");
1702 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1703 expectedResponse.setRequestReferences(requestReferences);
1704 uri = servInstanceuri + "v7"
1705 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1706 ResponseEntity<String> response =
1707 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1709 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1710 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1711 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1715 public void createNetworkInstance() throws IOException {
1716 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1717 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1718 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1720 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1721 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1722 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1723 .withStatus(HttpStatus.SC_OK)));
1725 wireMockServer.stubFor(
1726 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1727 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1728 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1729 .withStatus(HttpStatus.SC_OK)));
1731 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1732 + "modelName=GR-API-DEFAULT&action=createInstance"))
1733 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1734 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1735 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1737 // expected response
1738 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1739 RequestReferences requestReferences = new RequestReferences();
1740 requestReferences.setInstanceId("1882939");
1741 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1742 expectedResponse.setRequestReferences(requestReferences);
1743 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1744 ResponseEntity<String> response =
1745 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1747 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1748 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1749 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1753 public void updateNetworkInstance() throws IOException {
1754 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1755 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1756 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1758 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1759 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1760 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1761 .withStatus(HttpStatus.SC_OK)));
1763 wireMockServer.stubFor(
1764 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1765 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1766 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1767 .withStatus(HttpStatus.SC_OK)));
1769 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1770 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1771 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1772 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1773 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1774 // expected response
1775 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1776 RequestReferences requestReferences = new RequestReferences();
1777 requestReferences.setInstanceId("1882939");
1778 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1779 expectedResponse.setRequestReferences(requestReferences);
1780 uri = servInstanceuri + "v7"
1781 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1782 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, 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"));
1787 assertTrue(response.getBody().contains("1882939"));
1791 public void deleteNetworkInstance() throws IOException {
1792 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1793 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1794 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1796 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1797 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1798 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1799 .withStatus(HttpStatus.SC_OK)));
1801 wireMockServer.stubFor(
1802 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1803 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1804 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1805 .withStatus(HttpStatus.SC_OK)));
1807 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1808 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1809 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1810 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1811 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1813 // expected response
1814 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1815 RequestReferences requestReferences = new RequestReferences();
1816 requestReferences.setInstanceId("1882939");
1817 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1818 expectedResponse.setRequestReferences(requestReferences);
1819 uri = servInstanceuri + "v7"
1820 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1821 ResponseEntity<String> response =
1822 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1824 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1825 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1826 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1830 public void deleteNetworkInstanceNoReqParams() throws IOException {
1831 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1832 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1833 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1835 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1836 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1837 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1838 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1839 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1842 // expected response
1843 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1844 RequestReferences requestReferences = new RequestReferences();
1845 requestReferences.setInstanceId("1882939");
1846 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1847 expectedResponse.setRequestReferences(requestReferences);
1848 uri = servInstanceuri + "v6"
1849 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1850 ResponseEntity<String> response =
1851 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1853 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1854 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1855 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1859 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1861 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1862 expectedRecord.setRequestStatus("FAILED");
1863 expectedRecord.setStatusMessage("Error mapping request: ");
1864 expectedRecord.setProgress(100L);
1865 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1866 expectedRecord.setLastModifiedBy("APIH");
1867 expectedRecord.setRequestScope("network");
1868 expectedRecord.setRequestAction("deleteInstance");
1869 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1871 uri = servInstanceuri + "v6"
1872 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1873 ResponseEntity<String> response =
1874 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1878 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1882 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1883 uri = servInstanceuri + "v5"
1884 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1885 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1887 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1891 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1892 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1893 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1894 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1896 ServiceRecipe serviceRecipe = new ServiceRecipe();
1897 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1898 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1899 serviceRecipe.setAction(Action.createInstance.toString());
1900 serviceRecipe.setId(1);
1901 serviceRecipe.setRecipeTimeout(180);
1902 Service defaultService = new Service();
1903 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1905 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1906 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1907 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1909 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1910 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1911 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1913 uri = servInstanceuri + "v7" + "/serviceInstances";
1914 ResponseEntity<String> response =
1915 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1917 // expected response
1918 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1919 RequestReferences requestReferences = new RequestReferences();
1920 requestReferences.setInstanceId("1882939");
1921 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1922 expectedResponse.setRequestReferences(requestReferences);
1924 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1925 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1926 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1930 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1931 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1932 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1933 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1935 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1936 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1937 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1938 .withStatus(HttpStatus.SC_OK)));
1940 wireMockServer.stubFor(
1941 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1942 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1943 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1944 .withStatus(HttpStatus.SC_OK)));
1946 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1947 + "modelName=GR-API-DEFAULT&action=createInstance"))
1948 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1949 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1950 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1952 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1953 ResponseEntity<String> response =
1954 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1956 // expected response
1957 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1958 RequestReferences requestReferences = new RequestReferences();
1959 requestReferences.setInstanceId("1882939");
1960 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1961 expectedResponse.setRequestReferences(requestReferences);
1963 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1964 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1965 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1969 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1970 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1971 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1972 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1974 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1975 ResponseEntity<String> response =
1976 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1978 // expected response
1979 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1980 RequestReferences requestReferences = new RequestReferences();
1981 requestReferences.setInstanceId("1882939");
1982 expectedResponse.setRequestReferences(requestReferences);
1984 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1988 public void createNetworkInstanceTestApiGrApi() throws IOException {
1989 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1990 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1991 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1993 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1994 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1995 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1996 .withStatus(HttpStatus.SC_OK)));
1998 wireMockServer.stubFor(
1999 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2000 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2001 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2002 .withStatus(HttpStatus.SC_OK)));
2004 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2005 + "modelName=GR-API-DEFAULT&action=createInstance"))
2006 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2007 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2008 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2010 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2011 ResponseEntity<String> response =
2012 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2014 // expected response
2015 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2016 RequestReferences requestReferences = new RequestReferences();
2017 requestReferences.setInstanceId("1882939");
2018 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2019 expectedResponse.setRequestReferences(requestReferences);
2021 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2022 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2023 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2027 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2028 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2029 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2030 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2032 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2033 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2034 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2035 .withStatus(HttpStatus.SC_OK)));
2037 wireMockServer.stubFor(
2038 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2039 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2040 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2041 .withStatus(HttpStatus.SC_OK)));
2043 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2044 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2045 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2046 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2047 .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("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2053 // expected response
2054 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2055 RequestReferences requestReferences = new RequestReferences();
2056 requestReferences.setInstanceId("1882939");
2057 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2058 expectedResponse.setRequestReferences(requestReferences);
2060 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2061 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2062 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2066 public void activateServiceInstanceRequestStatus() throws IOException {
2067 ServiceRecipe serviceRecipe = new ServiceRecipe();
2068 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2069 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2070 serviceRecipe.setAction(Action.createInstance.toString());
2071 serviceRecipe.setId(1);
2072 serviceRecipe.setRecipeTimeout(180);
2073 Service defaultService = new Service();
2074 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2076 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2077 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2078 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2080 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2081 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2082 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2084 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2085 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2086 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2089 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2090 RequestReferences requestReferences = new RequestReferences();
2091 requestReferences.setInstanceId("1882939");
2092 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2093 expectedResponse.setRequestReferences(requestReferences);
2094 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2095 ResponseEntity<String> response =
2096 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2098 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2099 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2100 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2104 public void invalidRequestId() throws IOException {
2105 String illegalRequestId = "1234";
2106 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2107 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2108 uri = servInstanceuri + "v5/serviceInstances";
2109 ResponseEntity<String> response =
2110 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2112 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2113 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2117 public void invalidBPELResponse() throws IOException {
2119 ServiceRecipe serviceRecipe = new ServiceRecipe();
2120 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2121 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2122 serviceRecipe.setAction(Action.createInstance.toString());
2123 serviceRecipe.setId(1);
2124 serviceRecipe.setRecipeTimeout(180);
2125 Service defaultService = new Service();
2126 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2128 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2129 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2130 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2132 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2133 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2134 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2136 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2137 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2138 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2140 uri = servInstanceuri + "v5/serviceInstances";
2141 ResponseEntity<String> response =
2142 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2144 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2145 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2146 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2147 realResponse.getServiceException().getText());
2151 public void unauthorizedBPELResponse() throws IOException {
2153 ServiceRecipe serviceRecipe = new ServiceRecipe();
2154 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2155 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2156 serviceRecipe.setAction(Action.createInstance.toString());
2157 serviceRecipe.setId(1);
2158 serviceRecipe.setRecipeTimeout(180);
2159 Service defaultService = new Service();
2160 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2162 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2163 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2164 .withBodyFile("Camunda/UnauthorizedResponse.json")
2165 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2167 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2168 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2169 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2171 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2172 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2173 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2175 uri = servInstanceuri + "v5/serviceInstances";
2176 ResponseEntity<String> response =
2177 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2179 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2180 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2181 assertEquals("Exception caught mapping Camunda JSON response to object",
2182 realResponse.getServiceException().getText());
2186 public void invalidBPELResponse2() throws IOException {
2188 ServiceRecipe serviceRecipe = new ServiceRecipe();
2189 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2190 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2191 serviceRecipe.setAction(Action.createInstance.toString());
2192 serviceRecipe.setId(1);
2193 serviceRecipe.setRecipeTimeout(180);
2194 Service defaultService = new Service();
2195 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2197 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2198 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2199 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2201 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2202 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2203 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2205 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2206 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2207 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2208 uri = servInstanceuri + "v5/serviceInstances";
2209 ResponseEntity<String> response =
2210 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2212 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2213 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2214 assertTrue(realResponse.getServiceException().getText()
2215 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2219 public void createMacroServiceInstance() throws IOException {
2220 ServiceRecipe serviceRecipe = new ServiceRecipe();
2221 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2222 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2223 serviceRecipe.setAction(Action.createInstance.toString());
2224 serviceRecipe.setId(1);
2225 serviceRecipe.setRecipeTimeout(180);
2226 Service defaultService = new Service();
2227 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2229 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2230 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2231 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2233 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2234 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2235 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2237 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2239 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2241 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2242 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2243 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2246 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2247 RequestReferences requestReferences = new RequestReferences();
2248 requestReferences.setInstanceId("1882939");
2249 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2250 expectedResponse.setRequestReferences(requestReferences);
2251 uri = servInstanceUriPrev7 + "v5";
2252 ResponseEntity<String> response =
2253 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2256 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2257 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2258 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2262 public void testUserParams() throws IOException {
2263 ObjectMapper mapper = new ObjectMapper();
2264 ServiceInstancesRequest request =
2265 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2266 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2267 String userParamsTxt = inputStream("/userParams.txt");
2269 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2270 System.out.println(userParams);
2271 assertTrue(userParams.size() > 0);
2272 assertTrue(userParams.get(0).containsKey("name"));
2273 assertTrue(userParams.get(0).containsKey("value"));
2274 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2278 public void testConfigureCloudConfig() throws IOException {
2279 ObjectMapper mapper = new ObjectMapper();
2280 ServiceInstancesRequest request =
2281 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2282 CloudConfiguration cloudConfig =
2283 servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2285 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2286 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2290 public void testMapToLegacyRequest() throws IOException {
2291 ObjectMapper mapper = new ObjectMapper();
2292 ServiceInstancesRequest request =
2293 mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2294 ServiceInstancesRequest expected =
2295 mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2296 servInstances.mapToLegacyRequest(request.getRequestDetails());
2297 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2298 assertThat(request, sameBeanAs(expected));
2302 public void scaleOutVfModule() throws IOException {
2303 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2304 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2305 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2307 wireMockServer.stubFor(get(urlMatching(
2308 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
2309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2310 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2311 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2313 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
2314 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2315 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2316 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2318 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2319 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2320 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2321 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2324 wireMockServer.stubFor(get(urlMatching(
2325 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
2326 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2327 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2328 .withBody(getWiremockResponseForCatalogdb(
2329 "vnfComponentRecipeVfModuleScaleOut_Response.json"))
2330 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2332 wireMockServer.stubFor(get(urlMatching(
2333 ".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2335 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json"))
2336 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2338 // expected response
2339 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2340 RequestReferences requestReferences = new RequestReferences();
2341 requestReferences.setInstanceId("1882939");
2342 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2343 expectedResponse.setRequestReferences(requestReferences);
2344 uri = servInstanceuri + "v7"
2345 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2346 ResponseEntity<String> response =
2347 sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2349 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2350 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2351 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2352 assertTrue(response.getBody().contains("1882939"));
2356 public void createServiceInstanceBadResponse() throws IOException {
2357 ServiceRecipe serviceRecipe = new ServiceRecipe();
2358 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2359 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2360 serviceRecipe.setAction(Action.createInstance.toString());
2361 serviceRecipe.setId(1);
2362 serviceRecipe.setRecipeTimeout(180);
2363 Service defaultService = new Service();
2364 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2366 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2367 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2368 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2370 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2371 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2372 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2374 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2375 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2376 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2378 uri = servInstanceuri + "v5/serviceInstances";
2379 ResponseEntity<String> response =
2380 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2382 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2383 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2384 assertEquals("Exception caught mapping Camunda JSON response to object",
2385 realResponse.getServiceException().getText());
2389 public void createServiceInstanceDuplicateError() throws IOException {
2390 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2391 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2392 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2394 uri = servInstanceuri + "v5/serviceInstances";
2395 ResponseEntity<String> response =
2396 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2398 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2399 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2401 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2402 realResponse.getServiceException().getText());
2406 public void createServiceInstanceDuplicateHistoryCheck() throws IOException {
2407 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2408 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2409 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2410 .withStatus(HttpStatus.SC_ACCEPTED)));
2411 wireMockServer.stubFor(get(
2412 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2413 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2414 .withBodyFile("Camunda/HistoryCheckResponse.json")
2415 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2417 uri = servInstanceuri + "v5/serviceInstances";
2418 ResponseEntity<String> response =
2419 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2421 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2422 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2424 "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.",
2425 realResponse.getServiceException().getText());
2429 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException {
2430 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2431 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2432 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2433 .withStatus(HttpStatus.SC_ACCEPTED)));
2434 wireMockServer.stubFor(get(
2435 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2436 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2437 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2439 uri = servInstanceuri + "v5/serviceInstances";
2440 ResponseEntity<String> response =
2441 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2443 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2444 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2446 "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",
2447 realResponse.getServiceException().getText());
2451 public void createServiceInstanceDuplicate() throws IOException {
2452 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2453 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2454 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2456 uri = servInstanceuri + "v5/serviceInstances";
2457 ResponseEntity<String> response =
2458 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2460 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2461 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2463 "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2464 realResponse.getServiceException().getText());
2468 public void createServiceInstanceSaveError() throws IOException {
2469 ServiceRecipe serviceRecipe = new ServiceRecipe();
2470 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2471 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2472 serviceRecipe.setAction(Action.createInstance.toString());
2473 serviceRecipe.setId(1);
2474 serviceRecipe.setRecipeTimeout(180);
2475 Service defaultService = new Service();
2476 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2477 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2478 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2479 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2480 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2481 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2482 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2484 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2485 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2486 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2488 uri = servInstanceuri + "v5/serviceInstances";
2489 ResponseEntity<String> response =
2490 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2492 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2493 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2495 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2496 realResponse.getServiceException().getText());
2500 public void createPortConfigurationSaveError() throws IOException {
2501 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2502 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2503 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2504 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2505 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2506 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2508 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2509 ResponseEntity<String> response =
2510 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2512 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2513 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2515 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2516 realResponse.getServiceException().getText());
2520 public void createPortConfigDbUpdateError() throws IOException {
2521 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests/"))
2522 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2523 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2525 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2526 ResponseEntity<String> response =
2527 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2529 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2530 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2532 "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
2533 realResponse.getServiceException().getText());
2537 public void vnfUpdateWithNetworkInstanceGroup() throws IOException {
2538 TestAppender.events.clear();
2539 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2540 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2541 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2543 wireMockServer.stubFor(get(urlMatching(
2544 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2545 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2546 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2547 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2549 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
2550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2551 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2552 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2554 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
2555 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2556 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2557 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2558 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2559 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2561 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2562 RequestReferences requestReferences = new RequestReferences();
2563 requestReferences.setInstanceId("1882939");
2564 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2565 expectedResponse.setRequestReferences(requestReferences);
2566 uri = servInstanceuri
2567 + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2568 ResponseEntity<String> response =
2569 sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2571 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2572 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2573 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2574 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2576 for (ILoggingEvent logEvent : TestAppender.events) {
2577 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging")
2578 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
2579 Map<String, String> mdc = logEvent.getMDCPropertyMap();
2580 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2581 assertEquals("VID", mdc.get(PARTNERNAME));
2587 public void createInstanceGroup() throws IOException {
2588 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2589 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2590 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2593 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2594 RequestReferences requestReferences = new RequestReferences();
2595 requestReferences.setInstanceId("1882939");
2596 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2597 expectedResponse.setRequestReferences(requestReferences);
2598 uri = servInstanceuri + "/v7/instanceGroups";
2599 ResponseEntity<String> response =
2600 sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2603 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2604 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2605 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2609 public void deleteInstanceGroup() throws IOException {
2610 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2611 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2612 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2615 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2616 RequestReferences requestReferences = new RequestReferences();
2617 requestReferences.setInstanceId("1882939");
2618 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2619 expectedResponse.setRequestReferences(requestReferences);
2620 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2621 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2624 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2625 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2626 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2630 public void deleteInstanceGroupNoRequestIdHeader() throws IOException {
2631 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2632 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2634 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2635 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2636 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2640 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException {
2641 HttpHeaders noPartnerHeaders = new HttpHeaders();
2642 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2643 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2644 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2645 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2647 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2648 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2649 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2653 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException {
2654 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2655 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2656 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2658 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2659 RequestReferences requestReferences = new RequestReferences();
2660 requestReferences.setInstanceId("1882939");
2661 expectedResponse.setRequestReferences(requestReferences);
2662 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2663 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2666 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2667 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2668 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2672 public void addMembers() throws IOException {
2673 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2674 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2675 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2677 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2678 RequestReferences requestReferences = new RequestReferences();
2679 requestReferences.setInstanceId("1882939");
2680 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2681 expectedResponse.setRequestReferences(requestReferences);
2682 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2683 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2686 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2687 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2688 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2692 public void removeMembers() throws IOException {
2693 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2694 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2695 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2697 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2698 RequestReferences requestReferences = new RequestReferences();
2699 requestReferences.setInstanceId("1882939");
2700 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2701 expectedResponse.setRequestReferences(requestReferences);
2702 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2703 ResponseEntity<String> response =
2704 sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2707 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2708 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2709 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2713 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2714 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2715 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2716 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2718 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2719 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2720 .withStatus(HttpStatus.SC_NOT_FOUND)));
2722 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2723 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2724 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2725 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2726 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2728 // expected response
2729 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2730 RequestReferences requestReferences = new RequestReferences();
2731 requestReferences.setInstanceId("1882939");
2732 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2733 expectedResponse.setRequestReferences(requestReferences);
2734 uri = servInstanceuri + "v7"
2735 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2736 ResponseEntity<String> response =
2737 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2739 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2740 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2741 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2745 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2746 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2747 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2748 .withStatus(HttpStatus.SC_NOT_FOUND)));
2750 uri = servInstanceuri + "v7"
2751 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2752 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2754 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2755 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2756 assertEquals(realResponse.getServiceException().getText(),
2757 "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2761 public void setServiceTypeTestALaCarte() throws JsonProcessingException {
2762 String requestScope = ModelType.service.toString();
2763 Boolean aLaCarteFlag = true;
2764 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2765 RequestDetails requestDetails = new RequestDetails();
2766 RequestInfo requestInfo = new RequestInfo();
2767 requestInfo.setSource("VID");
2768 requestDetails.setRequestInfo(requestInfo);
2769 sir.setRequestDetails(requestDetails);
2770 Service defaultService = new Service();
2771 defaultService.setServiceType("testServiceTypeALaCarte");
2773 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2774 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2775 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2777 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2778 assertEquals(serviceType, "testServiceTypeALaCarte");
2782 public void setServiceTypeTest() throws JsonProcessingException {
2783 String requestScope = ModelType.service.toString();
2784 Boolean aLaCarteFlag = false;
2785 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2786 RequestDetails requestDetails = new RequestDetails();
2787 RequestInfo requestInfo = new RequestInfo();
2788 ModelInfo modelInfo = new ModelInfo();
2789 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2790 requestInfo.setSource("VID");
2791 requestDetails.setModelInfo(modelInfo);
2792 requestDetails.setRequestInfo(requestInfo);
2793 sir.setRequestDetails(requestDetails);
2794 Service defaultService = new Service();
2795 defaultService.setServiceType("testServiceType");
2797 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2798 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2799 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2801 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2802 assertEquals(serviceType, "testServiceType");
2806 public void setServiceTypeTestDefault() throws JsonProcessingException {
2807 String requestScope = ModelType.service.toString();
2808 Boolean aLaCarteFlag = false;
2809 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2810 RequestDetails requestDetails = new RequestDetails();
2811 RequestInfo requestInfo = new RequestInfo();
2812 ModelInfo modelInfo = new ModelInfo();
2813 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2814 requestInfo.setSource("VID");
2815 requestDetails.setModelInfo(modelInfo);
2816 requestDetails.setRequestInfo(requestInfo);
2817 sir.setRequestDetails(requestDetails);
2818 Service defaultService = new Service();
2819 defaultService.setServiceType("testServiceType");
2821 wireMockServer.stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2822 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2823 .withStatus(HttpStatus.SC_NOT_FOUND)));
2824 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
2825 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2826 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2828 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2829 assertEquals(serviceType, "testServiceType");
2833 public void setServiceTypeTestNetwork() throws JsonProcessingException {
2834 String requestScope = ModelType.network.toString();
2835 Boolean aLaCarteFlag = null;
2836 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2837 RequestDetails requestDetails = new RequestDetails();
2838 RequestInfo requestInfo = new RequestInfo();
2839 ModelInfo modelInfo = new ModelInfo();
2840 modelInfo.setModelName("networkModelName");
2841 requestInfo.setSource("VID");
2842 requestDetails.setModelInfo(modelInfo);
2843 requestDetails.setRequestInfo(requestInfo);
2844 sir.setRequestDetails(requestDetails);
2846 String serviceType = requestHandlerUtils.getServiceType(requestScope, sir, aLaCarteFlag);
2847 assertEquals(serviceType, "networkModelName");
2851 public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException {
2852 String requestScope = "instanceGroup";
2853 ServiceInstancesRequest sir =
2854 mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
2855 assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc",
2856 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2860 public void setServiceInstanceIdTest() {
2861 String requestScope = "vnf";
2862 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2863 sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2864 assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f",
2865 requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2869 public void setServiceInstanceIdReturnNullTest() {
2870 String requestScope = "vnf";
2871 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2872 assertNull(requestHandlerUtils.setServiceInstanceId(requestScope, sir));
2876 public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException {
2877 wireMockServer.stubFor(get(
2878 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2879 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2880 .withBodyFile("Camunda/HistoryCheckResponse.json")
2881 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2883 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2884 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2885 boolean inProgress = false;
2886 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2887 assertTrue(inProgress);
2891 public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException {
2892 wireMockServer.stubFor(get(
2893 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2894 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2895 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
2897 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2898 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2899 boolean inProgress = false;
2900 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2901 assertFalse(inProgress);
2905 public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException {
2906 wireMockServer.stubFor(get(
2907 ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2908 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2909 .withBodyFile("Camunda/HistoryCheckResponseCompleted.json")
2910 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2912 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2913 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2914 boolean inProgress = false;
2915 inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null);
2916 assertFalse(inProgress);
2920 public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException {
2921 String replaceVfModule = inputStream("/ReplaceVfModule.json");
2922 ObjectMapper mapper = new ObjectMapper();
2923 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2924 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2925 assertEquals(Action.replaceInstance, action);
2929 public void handleReplaceInstance_retainAssignments_Test()
2930 throws JsonParseException, JsonMappingException, IOException {
2931 String replaceVfModule = inputStream("/ReplaceVfModuleRetainAssignments.json");
2932 ObjectMapper mapper = new ObjectMapper();
2933 ServiceInstancesRequest sir = mapper.readValue(replaceVfModule, ServiceInstancesRequest.class);
2934 Actions action = servInstances.handleReplaceInstance(Action.replaceInstance, sir);
2935 assertEquals(Action.replaceInstanceRetainAssignments, action);
2938 * @Test public void buildSelfLinkUrlTest() throws Exception { // v - version String incomingUrl =
2939 * "http://localhost:8080/onap/infra/so/serviceInstantiation/v7/serviceInstances"; String expectedSelfLink =
2940 * "http://localhost:8080/orchestrationRequests/v7/efce3167-5e45-4666-9d4d-22e23648e5d1"; String requestId =
2941 * "efce3167-5e45-4666-9d4d-22e23648e5d1"; Optional<URL> actualSelfLinkUrl = buildSelfLinkUrl(incomingUrl,
2942 * requestId); assertEquals(expectedSelfLink, actualSelfLinkUrl.get().toString()); // V - Version String
2943 * incomingUrlV = "http://localhost:8080/onap/infra/so/serviceInstantiation/V7/serviceInstances"; String
2944 * expectedSelfLinkV = "http://localhost:8080/orchestrationRequests/V7/efce3167-5e45-4666-9d4d-22e23648e5d1";
2945 * Optional<URL> actualSelfLinkUrlV = buildSelfLinkUrl(incomingUrlV, requestId); assertEquals(expectedSelfLinkV,
2946 * actualSelfLinkUrlV.get().toString()); }