2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.apihandlerinfra;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
29 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertFalse;
32 import static org.junit.Assert.assertNotNull;
33 import static org.junit.Assert.assertNull;
34 import static org.junit.Assert.assertThat;
35 import static org.junit.Assert.assertTrue;
36 import static org.onap.logging.filter.base.Constants.HttpHeaders.ONAP_REQUEST_ID;
37 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
38 import static org.onap.logging.filter.base.Constants.HttpHeaders.TRANSACTION_ID;
39 import static org.onap.logging.filter.base.Constants.HttpHeaders.CLIENT_ID;
41 import java.io.IOException;
42 import java.net.MalformedURLException;
44 import java.nio.file.Files;
45 import java.nio.file.Paths;
46 import java.util.List;
48 import javax.ws.rs.core.MediaType;
49 import javax.ws.rs.core.Response;
50 import org.apache.http.HttpStatus;
51 import org.junit.Before;
52 import org.junit.Test;
53 import org.mockito.Mockito;
54 import org.onap.logging.ref.slf4j.ONAPLogConstants;
55 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
56 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
57 import org.onap.so.db.catalog.beans.Service;
58 import org.onap.so.db.catalog.beans.ServiceRecipe;
59 import org.onap.so.db.request.beans.InfraActiveRequests;
60 import org.onap.so.serviceinstancebeans.CloudConfiguration;
61 import org.onap.so.serviceinstancebeans.ModelInfo;
62 import org.onap.so.serviceinstancebeans.ModelType;
63 import org.onap.so.serviceinstancebeans.RequestDetails;
64 import org.onap.so.serviceinstancebeans.RequestError;
65 import org.onap.so.serviceinstancebeans.RequestInfo;
66 import org.onap.so.serviceinstancebeans.RequestParameters;
67 import org.onap.so.serviceinstancebeans.RequestReferences;
68 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
69 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
70 import org.springframework.beans.factory.annotation.Autowired;
71 import org.springframework.beans.factory.annotation.Value;
72 import org.springframework.http.HttpEntity;
73 import org.springframework.http.HttpHeaders;
74 import org.springframework.http.HttpMethod;
75 import org.springframework.http.ResponseEntity;
76 import org.springframework.util.ResourceUtils;
77 import org.springframework.web.util.UriComponentsBuilder;
78 import com.fasterxml.jackson.core.JsonParseException;
79 import com.fasterxml.jackson.core.JsonProcessingException;
80 import com.fasterxml.jackson.databind.DeserializationFeature;
81 import com.fasterxml.jackson.databind.JsonMappingException;
82 import com.fasterxml.jackson.databind.ObjectMapper;
83 import com.github.tomakehurst.wiremock.http.Fault;
84 import ch.qos.logback.classic.spi.ILoggingEvent;
86 public class ServiceInstancesTest extends BaseTest {
88 private final ObjectMapper mapper = new ObjectMapper();
89 private ObjectMapper errorMapper = new ObjectMapper();
92 private ServiceInstances servInstances;
95 private RequestHandlerUtils requestHandlerUtils;
97 @Value("${wiremock.server.port}")
98 private String wiremockPort;
100 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
101 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
103 private URL selfLink;
104 private URL initialUrl;
105 private int initialPort;
106 private HttpHeaders headers;
109 public void beforeClass() {
110 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
111 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
112 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
114 headers = new HttpHeaders();
115 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
116 headers.set(TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
117 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
118 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
119 headers.set(CLIENT_ID, "VID");
120 headers.set(REQUESTOR_ID, "xxxxxx");
121 try { // generate one-time port number to avoid RANDOM port number later.
122 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
123 initialPort = initialUrl.getPort();
124 } catch (MalformedURLException e) {
127 wireMockServer.stubFor(post(urlMatching(".*/infraActiveRequests.*")).willReturn(aResponse()
128 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_OK)));
129 Mockito.doReturn(null).when(requestsDbClient).getInfraActiveRequestbyRequestId(Mockito.any());
132 public String inputStream(String JsonInput) throws IOException {
133 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
134 return new String(Files.readAllBytes(Paths.get(JsonInput)));
137 private URL createExpectedSelfLink(String version, String requestId) {
138 System.out.println("createdUrl: " + initialUrl.toString());
140 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
141 } catch (MalformedURLException e) {
147 private String getWiremockResponseForCatalogdb(String file) {
149 File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
150 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
151 "localhost:" + wiremockPort);
152 } catch (IOException e) {
159 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod,
160 HttpHeaders headers) {
162 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
163 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
165 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
166 headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
169 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
171 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
173 return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class);
176 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod) {
177 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
181 public void createServiceInstanceVIDDefault() throws IOException {
182 TestAppender.events.clear();
184 ServiceRecipe serviceRecipe = new ServiceRecipe();
185 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
186 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
187 serviceRecipe.setAction(Action.createInstance.toString());
188 serviceRecipe.setId(1);
189 serviceRecipe.setRecipeTimeout(180);
190 Service defaultService = new Service();
191 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
194 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
195 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
196 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
198 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
199 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
200 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
202 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
204 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
207 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
208 RequestReferences requestReferences = new RequestReferences();
209 requestReferences.setInstanceId("1882939");
210 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
211 expectedResponse.setRequestReferences(requestReferences);
212 uri = servInstanceuri + "v5/serviceInstances";
213 ResponseEntity<String> response =
214 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
217 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
218 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
219 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
223 for (ILoggingEvent logEvent : TestAppender.events)
224 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter")
225 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
226 Map<String, String> mdc = logEvent.getMDCPropertyMap();
227 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
228 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
229 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
230 assertEquals("UNKNOWN", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
231 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",
232 mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
233 assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
234 } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter")
235 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) {
236 Map<String, String> mdc = logEvent.getMDCPropertyMap();
237 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
238 assertNotNull(mdc.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP));
239 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
240 assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
241 assertEquals("202", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
242 assertEquals("UNKNOWN", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
243 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",
244 mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
245 assertEquals("COMPLETE", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
246 assertNotNull(mdc.get(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION));
247 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
248 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
249 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
254 public void createServiceInstanceServiceInstancesUri() throws IOException {
255 ServiceRecipe serviceRecipe = new ServiceRecipe();
256 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
257 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
258 serviceRecipe.setAction(Action.createInstance.toString());
259 serviceRecipe.setId(1);
260 serviceRecipe.setRecipeTimeout(180);
261 Service defaultService = new Service();
262 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
264 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
265 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
266 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
269 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
270 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
271 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
273 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
274 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
275 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
277 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
278 RequestReferences requestReferences = new RequestReferences();
279 requestReferences.setInstanceId("1882939");
280 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
281 expectedResponse.setRequestReferences(requestReferences);
282 uri = servInstanceuri + "v5";
283 ResponseEntity<String> response =
284 sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
287 assertEquals(404, response.getStatusCode().value());
288 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
292 public void createServiceInstanceBpelStatusError() throws IOException {
293 ServiceRecipe serviceRecipe = new ServiceRecipe();
294 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
295 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
296 serviceRecipe.setAction(Action.createInstance.toString());
297 serviceRecipe.setId(1);
298 serviceRecipe.setRecipeTimeout(180);
299 Service defaultService = new Service();
300 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
303 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
304 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
305 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
308 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
310 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
312 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
313 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
314 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
316 uri = servInstanceuri + "v5/serviceInstances";
317 ResponseEntity<String> response =
318 sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
320 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
324 public void createServiceInstanceBadGateway() throws IOException {
325 ServiceRecipe serviceRecipe = new ServiceRecipe();
326 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
327 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
328 serviceRecipe.setAction(Action.createInstance.toString());
329 serviceRecipe.setId(1);
330 serviceRecipe.setRecipeTimeout(180);
331 Service defaultService = new Service();
332 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
334 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
335 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
337 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
339 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
341 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
342 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
343 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
345 uri = servInstanceuri + "v5/serviceInstances";
346 ResponseEntity<String> response =
347 sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
349 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
353 public void createServiceInstanceEmptyResponse() throws IOException {
354 ServiceRecipe serviceRecipe = new ServiceRecipe();
355 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
356 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
357 serviceRecipe.setAction(Action.createInstance.toString());
358 serviceRecipe.setId(1);
359 serviceRecipe.setRecipeTimeout(180);
360 Service defaultService = new Service();
361 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
363 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
364 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
366 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
367 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
368 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
370 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
371 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
372 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
374 uri = servInstanceuri + "v5/serviceInstances";
375 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
377 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
381 public void activateServiceInstanceNoRecipeALaCarte() throws IOException {
382 TestAppender.events.clear();
383 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
384 HttpHeaders requestIDheaders = new HttpHeaders();
385 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
386 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri,
387 HttpMethod.POST, requestIDheaders);
389 Service defaultService = new Service();
390 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
392 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
393 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
394 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
397 wireMockServer.stubFor(get(urlMatching(
398 ".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
400 .withStatus(HttpStatus.SC_NOT_FOUND)));
402 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
404 for (ILoggingEvent logEvent : TestAppender.events) {
405 if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.SOAuditLogContainerFilter")
406 && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) {
407 Map<String, String> mdc = logEvent.getMDCPropertyMap();
408 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
409 assertNotNull(mdc.get("PartnerName"));
415 public void activateServiceInstanceNoRecipe() throws IOException {
416 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
417 Service defaultService = new Service();
418 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
419 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
420 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
421 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
423 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search/.*")).willReturn(aResponse()
424 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
426 ResponseEntity<String> response =
427 sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
429 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
433 public void activateServiceInstance() throws IOException {
434 ServiceRecipe serviceRecipe = new ServiceRecipe();
435 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
436 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
437 serviceRecipe.setAction(Action.createInstance.toString());
438 serviceRecipe.setId(1);
439 serviceRecipe.setRecipeTimeout(180);
440 Service defaultService = new Service();
441 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
443 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
445 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
447 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
448 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
449 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
451 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
452 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
453 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
455 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
456 RequestReferences requestReferences = new RequestReferences();
457 requestReferences.setInstanceId("1882939");
458 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
459 expectedResponse.setRequestReferences(requestReferences);
460 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
461 ResponseEntity<String> response =
462 sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
464 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
465 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
466 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
470 public void deactivateServiceInstance() throws IOException {
472 ServiceRecipe serviceRecipe = new ServiceRecipe();
473 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
474 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
475 serviceRecipe.setAction(Action.createInstance.toString());
476 serviceRecipe.setId(1);
477 serviceRecipe.setRecipeTimeout(180);
478 Service defaultService = new Service();
479 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
481 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
482 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
483 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
485 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
487 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
489 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
490 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
491 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
493 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
495 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
498 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
499 RequestReferences requestReferences = new RequestReferences();
500 requestReferences.setInstanceId("1882939");
501 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
502 expectedResponse.setRequestReferences(requestReferences);
503 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
504 ResponseEntity<String> response =
505 sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
507 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
508 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
509 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
513 public void deleteServiceInstance() throws IOException {
514 ServiceRecipe serviceRecipe = new ServiceRecipe();
515 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
516 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
517 serviceRecipe.setAction(Action.createInstance.toString());
518 serviceRecipe.setId(1);
519 serviceRecipe.setRecipeTimeout(180);
520 Service defaultService = new Service();
521 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
523 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
524 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
525 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
527 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
528 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
529 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
531 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
532 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
533 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
535 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
536 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
537 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
539 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
540 RequestReferences requestReferences = new RequestReferences();
541 requestReferences.setInstanceId("1882939");
542 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
543 expectedResponse.setRequestReferences(requestReferences);
544 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
545 ResponseEntity<String> response =
546 sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
548 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
549 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
550 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
554 public void assignServiceInstance() throws IOException {
555 ServiceRecipe serviceRecipe = new ServiceRecipe();
556 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
557 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
558 serviceRecipe.setAction(Action.createInstance.toString());
559 serviceRecipe.setId(1);
560 serviceRecipe.setRecipeTimeout(180);
561 Service defaultService = new Service();
562 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
564 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
565 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
566 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
568 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
569 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
570 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
572 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
573 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
574 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
576 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
577 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
578 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
580 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
581 RequestReferences requestReferences = new RequestReferences();
582 requestReferences.setInstanceId("1882939");
583 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
584 expectedResponse.setRequestReferences(requestReferences);
585 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
586 ResponseEntity<String> response =
587 sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
589 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
590 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
591 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
595 public void unassignServiceInstance() throws IOException {
596 ServiceRecipe serviceRecipe = new ServiceRecipe();
597 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
598 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
599 serviceRecipe.setAction(Action.createInstance.toString());
600 serviceRecipe.setId(1);
601 serviceRecipe.setRecipeTimeout(180);
602 Service defaultService = new Service();
603 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
605 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
606 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
607 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
609 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
610 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
611 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
613 wireMockServer.stubFor(get(urlMatching(".*/service/search/.*"))
614 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
615 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
617 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
618 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
619 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
621 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
622 RequestReferences requestReferences = new RequestReferences();
623 requestReferences.setInstanceId("1882939");
624 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
625 expectedResponse.setRequestReferences(requestReferences);
626 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
627 ResponseEntity<String> response =
628 sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
630 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
631 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
632 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
636 public void createPortConfiguration() throws IOException {
637 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
638 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
639 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
641 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
642 RequestReferences requestReferences = new RequestReferences();
643 requestReferences.setInstanceId("1882939");
644 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
645 expectedResponse.setRequestReferences(requestReferences);
646 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
647 ResponseEntity<String> response =
648 sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
650 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
651 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
652 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
653 assertTrue(response.getBody().contains("1882939"));
657 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
658 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
659 ResponseEntity<String> response =
660 sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
662 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
666 public void deletePortConfiguration() throws IOException {
667 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
668 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
669 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
672 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
673 RequestReferences requestReferences = new RequestReferences();
674 requestReferences.setInstanceId("1882939");
675 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
676 expectedResponse.setRequestReferences(requestReferences);
677 uri = servInstanceuri + "v7"
678 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
679 ResponseEntity<String> response =
680 sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
682 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
683 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
684 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
688 public void enablePort() throws IOException {
689 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
690 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
691 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
693 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
694 RequestReferences requestReferences = new RequestReferences();
695 requestReferences.setInstanceId("1882939");
696 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
697 expectedResponse.setRequestReferences(requestReferences);
698 uri = servInstanceuri + "v7"
699 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
700 ResponseEntity<String> response =
701 sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
703 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
704 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
705 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
709 public void disablePort() throws IOException {
710 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
711 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
712 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
714 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
715 RequestReferences requestReferences = new RequestReferences();
716 requestReferences.setInstanceId("1882939");
717 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
718 expectedResponse.setRequestReferences(requestReferences);
719 uri = servInstanceuri + "v7"
720 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
721 ResponseEntity<String> response =
722 sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
724 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
725 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
726 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
730 public void activatePort() throws IOException {
731 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
732 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
733 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
735 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
736 RequestReferences requestReferences = new RequestReferences();
737 requestReferences.setInstanceId("1882939");
738 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
739 expectedResponse.setRequestReferences(requestReferences);
740 uri = servInstanceuri + "v7"
741 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
742 ResponseEntity<String> response =
743 sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
745 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
746 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
747 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
751 public void deactivatePort() throws IOException {
752 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
753 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
754 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
756 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
757 RequestReferences requestReferences = new RequestReferences();
758 requestReferences.setInstanceId("1882939");
759 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
760 expectedResponse.setRequestReferences(requestReferences);
761 uri = servInstanceuri + "v7"
762 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
763 ResponseEntity<String> response =
764 sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
766 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
767 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
768 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
772 public void addRelationships() throws IOException {
773 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
774 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
775 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
777 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
778 RequestReferences requestReferences = new RequestReferences();
779 requestReferences.setInstanceId("1882939");
780 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
781 expectedResponse.setRequestReferences(requestReferences);
782 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
783 ResponseEntity<String> response =
784 sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
786 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
787 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
788 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
792 public void removeRelationships() throws IOException {
793 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
794 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
795 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
797 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
798 RequestReferences requestReferences = new RequestReferences();
799 requestReferences.setInstanceId("1882939");
800 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
801 expectedResponse.setRequestReferences(requestReferences);
802 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
803 ResponseEntity<String> response =
804 sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
806 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
807 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
808 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
812 public void createVnfInstanceNoALaCarte() throws IOException {
813 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
814 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
815 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
818 wireMockServer.stubFor(get(urlMatching(
819 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
820 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
821 .withBody(getWiremockResponseForCatalogdb(
822 "vnfResourceCustomization_ReplaceVnf_Response.json"))
823 .withStatus(org.apache.http.HttpStatus.SC_OK)));
825 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
826 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
827 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
828 .withStatus(org.apache.http.HttpStatus.SC_OK)));
830 wireMockServer.stubFor(get(urlMatching(
831 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
832 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
833 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
834 .withStatus(org.apache.http.HttpStatus.SC_OK)));
837 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
838 RequestReferences requestReferences = new RequestReferences();
839 requestReferences.setInstanceId("1882939");
840 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
841 expectedResponse.setRequestReferences(requestReferences);
842 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
843 ResponseEntity<String> response =
844 sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
846 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
847 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
848 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
852 public void createVnfInstance() throws IOException {
853 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
854 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
855 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
857 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
858 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
859 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
860 .withStatus(org.apache.http.HttpStatus.SC_OK)));
861 wireMockServer.stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
862 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
863 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
864 .withStatus(org.apache.http.HttpStatus.SC_OK)));
867 wireMockServer.stubFor(
868 get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
869 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
870 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
871 .withStatus(org.apache.http.HttpStatus.SC_OK)));
873 wireMockServer.stubFor(get(urlMatching(
874 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
875 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
876 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
877 .withStatus(org.apache.http.HttpStatus.SC_OK)));
880 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
881 RequestReferences requestReferences = new RequestReferences();
882 requestReferences.setInstanceId("1882939");
883 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
884 expectedResponse.setRequestReferences(requestReferences);
885 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
886 ResponseEntity<String> response =
887 sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
889 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
890 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
891 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
892 assertTrue(response.getBody().contains("1882939"));
896 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
897 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
898 ResponseEntity<String> response =
899 sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
901 assertEquals(404, response.getStatusCode().value());
905 public void createVnfInstanceInvalidVnfResource() throws IOException {
906 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
907 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
909 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
910 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
911 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
915 public void replaceVnfInstance() throws IOException {
916 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
917 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
918 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
920 wireMockServer.stubFor(get(urlMatching(
921 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002671"))
922 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
923 .withBody(getWiremockResponseForCatalogdb(
924 "vnfResourceCustomization_ReplaceVnf_Response.json"))
925 .withStatus(org.apache.http.HttpStatus.SC_OK)));
927 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/1/vnfResources"))
928 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
929 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
930 .withStatus(org.apache.http.HttpStatus.SC_OK)));
932 wireMockServer.stubFor(get(urlMatching(
933 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
934 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
935 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
936 .withStatus(org.apache.http.HttpStatus.SC_OK)));
938 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
939 RequestReferences requestReferences = new RequestReferences();
940 requestReferences.setInstanceId("1882939");
941 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
942 expectedResponse.setRequestReferences(requestReferences);
943 uri = servInstanceuri + "v7"
944 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
945 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
947 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
948 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
949 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
953 public void replaceVnfRecreateInstance() throws IOException {
954 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
955 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
956 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
958 wireMockServer.stubFor(get(urlMatching(
959 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
960 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
961 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
962 .withStatus(org.apache.http.HttpStatus.SC_OK)));
964 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
965 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
966 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
967 .withStatus(org.apache.http.HttpStatus.SC_OK)));
969 wireMockServer.stubFor(get(urlMatching(
970 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
971 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
972 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
973 .withStatus(org.apache.http.HttpStatus.SC_OK)));
976 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
977 RequestReferences requestReferences = new RequestReferences();
978 requestReferences.setInstanceId("1882939");
979 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
980 expectedResponse.setRequestReferences(requestReferences);
981 uri = servInstanceuri + "v7"
982 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
983 ResponseEntity<String> response =
984 sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
985 logger.debug(response.getBody());
987 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
988 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
989 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
993 public void recreateVnfInstance() throws IOException {
994 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
995 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
996 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
998 wireMockServer.stubFor(get(urlMatching(
999 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1000 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1001 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
1002 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1004 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1005 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1006 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1007 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1009 wireMockServer.stubFor(get(urlMatching(
1010 ".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1011 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1012 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1013 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1015 // expected response
1016 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1017 RequestReferences requestReferences = new RequestReferences();
1018 requestReferences.setInstanceId("1882939");
1019 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1020 expectedResponse.setRequestReferences(requestReferences);
1021 uri = servInstanceuri + "v7"
1022 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1023 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1024 logger.debug(response.getBody());
1026 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1027 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1028 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1032 public void updateVnfInstance() throws IOException {
1033 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1034 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1035 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1037 wireMockServer.stubFor(get(urlMatching(
1038 ".*/vnfResourceCustomization/search/findByModelCustomizationUUID[?]MODEL_CUSTOMIZATION_UUID=68dc9a92-214c-11e7-93ae-92361f002674"))
1039 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1040 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1041 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1043 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/4/vnfResources"))
1044 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1045 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1046 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1048 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1049 + "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1050 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1051 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1052 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1054 // expected response
1055 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1056 RequestReferences requestReferences = new RequestReferences();
1057 requestReferences.setInstanceId("1882939");
1058 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1059 expectedResponse.setRequestReferences(requestReferences);
1060 uri = servInstanceuri + "v7"
1061 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1062 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1064 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1065 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1066 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1070 public void applyUpdatedConfig() throws IOException {
1071 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1072 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1073 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1076 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1077 + "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1078 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1079 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1080 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1082 // expected response
1083 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1084 RequestReferences requestReferences = new RequestReferences();
1085 requestReferences.setInstanceId("1882939");
1086 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1087 expectedResponse.setRequestReferences(requestReferences);
1088 uri = servInstanceuri + "v7"
1089 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1090 ResponseEntity<String> response =
1091 sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1093 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1094 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1095 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1099 public void deleteVnfInstanceV5() throws IOException {
1100 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1101 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1102 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1104 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction"
1105 + "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1106 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1107 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1108 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1109 // expected response
1110 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1111 RequestReferences requestReferences = new RequestReferences();
1112 requestReferences.setInstanceId("1882939");
1113 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1114 expectedResponse.setRequestReferences(requestReferences);
1115 uri = servInstanceuri + "v5"
1116 + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1117 ResponseEntity<String> response =
1118 sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1120 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1121 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1122 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1126 public void createVfModuleInstance() throws IOException {
1127 wireMockServer.stubFor(get(urlMatching(
1128 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1129 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1130 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1131 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1133 wireMockServer.stubFor(get(urlMatching("/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1134 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1135 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1136 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1138 wireMockServer.stubFor(get(urlMatching("/vfModuleCustomization/1/vfModule"))
1139 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1140 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1141 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1143 wireMockServer.stubFor(get(urlMatching(
1144 "/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc\\?MODEL_CUSTOMIZATION_UUID=20c4431c-246d-11e7-93ae-92361f002671"))
1145 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1146 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1147 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1149 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1150 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1151 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1153 wireMockServer.stubFor(get(urlMatching(
1154 "/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1155 + "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1156 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1157 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1158 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1159 // expected response
1160 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1161 RequestReferences requestReferences = new RequestReferences();
1162 requestReferences.setInstanceId("1882939");
1163 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1164 expectedResponse.setRequestReferences(requestReferences);
1165 uri = servInstanceuri + "v7"
1166 + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1167 ResponseEntity<String> response =
1168 sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1170 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1171 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1172 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1173 assertTrue(response.getBody().contains("1882939"));
1177 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1178 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1179 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1180 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1182 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1183 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1184 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1185 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1188 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1189 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1190 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1191 .withBody(getWiremockResponseForCatalogdb(
1192 "vnfResourceCustomizationForVfModule_Response.json"))
1193 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1195 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1196 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1197 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1198 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1200 wireMockServer.stubFor(get(urlMatching(
1201 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDAndVfModuleModelUUIDOrderByCreatedDesc[?]"
1202 + "MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672&MODEL_UUID=066de97e-253e-11e7-93ae-92361f002672"))
1203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1204 .withBody(getWiremockResponseForCatalogdb(
1205 "vfModuleCustomizationPCM_Response.json"))
1206 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1208 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1209 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1210 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1211 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1213 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1214 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1215 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1216 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1219 wireMockServer.stubFor(
1220 get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction"
1221 + "[?]vnfComponentType=vfModule&action=createInstance"))
1222 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1223 .withBody(getWiremockResponseForCatalogdb(
1224 "vnfComponentRecipeVNF_API_Response.json"))
1225 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1227 // expected response
1228 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1229 RequestReferences requestReferences = new RequestReferences();
1230 requestReferences.setInstanceId("1882939");
1231 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1232 expectedResponse.setRequestReferences(requestReferences);
1233 uri = servInstanceuri + "v6"
1234 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1235 ResponseEntity<String> response =
1236 sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1237 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1238 ObjectMapper mapper = new ObjectMapper();
1239 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1240 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1244 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1245 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1246 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1247 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1249 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/.*"))
1250 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1251 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1252 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1255 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1256 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1257 .withBody(getWiremockResponseForCatalogdb(
1258 "vnfResourceCustomizationForVfModule_Response.json"))
1259 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1261 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1262 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1263 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1264 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1266 wireMockServer.stubFor(get(urlMatching(
1267 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002672"))
1268 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1269 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1270 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1272 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/2/vfModule"))
1273 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1274 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1275 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1277 wireMockServer.stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1278 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1279 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1280 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1282 wireMockServer.stubFor(get(urlMatching(
1283 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1284 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1286 .withBody(getWiremockResponseForCatalogdb(
1287 "vnfComponentRecipeDeleteVfModule_Response.json"))
1288 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1290 // expected response
1291 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1292 RequestReferences requestReferences = new RequestReferences();
1293 requestReferences.setInstanceId("1882939");
1294 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1295 expectedResponse.setRequestReferences(requestReferences);
1296 uri = servInstanceuri + "v6"
1297 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1298 ResponseEntity<String> response =
1299 sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1302 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1303 ObjectMapper mapper = new ObjectMapper();
1304 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1305 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1309 public void createVfModuleInstanceNoRecipe() throws IOException {
1311 wireMockServer.stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1312 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1313 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1314 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1317 .stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources"
1318 + "[?]MODEL_INSTANCE_NAME=test&VNF_RESOURCE_MODEL_UUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1319 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1320 .withBody(getWiremockResponseForCatalogdb(
1321 "vnfResourceCustomizationForVfModule_Response.json"))
1322 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1324 wireMockServer.stubFor(get(urlMatching(".*/vnfResourceCustomization/3/vfModuleCustomizations"))
1325 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1326 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1327 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1329 wireMockServer.stubFor(
1330 get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]"
1331 + "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1332 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1333 .withBody(getWiremockResponseForCatalogdb(
1334 "vfModuleCustomizationPCM_Response.json"))
1335 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1337 uri = servInstanceuri + "v6"
1338 + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1339 ResponseEntity<String> response =
1340 sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1342 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1343 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1344 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1348 public void replaceVfModuleInstance() throws IOException {
1349 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1350 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1351 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1354 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1355 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1356 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1357 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1358 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1360 wireMockServer.stubFor(get(urlMatching(
1361 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1362 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1363 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1364 .withBody(getWiremockResponseForCatalogdb(
1365 "vnfComponentRecipeDeleteVfModule_Response.json"))
1366 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1367 // expected response
1368 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1369 RequestReferences requestReferences = new RequestReferences();
1370 requestReferences.setInstanceId("1882939");
1371 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1372 expectedResponse.setRequestReferences(requestReferences);
1373 uri = servInstanceuri + "v7"
1374 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1375 ResponseEntity<String> response =
1376 sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1378 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1379 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1380 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1384 public void updateVfModuleInstance() throws IOException {
1385 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1386 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1387 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1389 wireMockServer.stubFor(get(urlMatching(
1390 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=cb82ffd8-252a-11e7-93ae-92361f002671"))
1391 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1392 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1393 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1395 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1396 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1397 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1398 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1400 wireMockServer.stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1401 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1402 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1403 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1405 wireMockServer.stubFor(get(urlMatching(
1406 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1407 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1408 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1409 .withBody(getWiremockResponseForCatalogdb(
1410 "vnfComponentRecipe_GRAPI_Response.json"))
1411 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1413 // expected response
1414 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1415 RequestReferences requestReferences = new RequestReferences();
1416 requestReferences.setInstanceId("1882939");
1417 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1418 expectedResponse.setRequestReferences(requestReferences);
1419 uri = servInstanceuri + "v7"
1420 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1421 ResponseEntity<String> response =
1422 sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1423 logger.debug(response.getBody());
1425 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1426 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1427 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1431 public void createVfModuleNoModelType() throws IOException {
1432 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1433 expectedRecord.setRequestStatus("FAILED");
1434 expectedRecord.setAction("createInstance");
1435 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1436 expectedRecord.setProgress(100L);
1437 expectedRecord.setSource("VID");
1438 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1439 expectedRecord.setLastModifiedBy("APIH");
1440 expectedRecord.setVfModuleName("testVfModule2");
1441 expectedRecord.setVfModuleModelName("serviceModel");
1442 expectedRecord.setRequestScope("vfModule");
1443 expectedRecord.setRequestAction("createInstance");
1444 expectedRecord.setRequestorId("zz9999");
1445 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1446 // VnfType is not sent in this request, should be blank in db
1447 expectedRecord.setVnfType("");
1448 uri = servInstanceuri
1449 + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1451 ResponseEntity<String> response =
1452 sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1454 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1458 public void inPlaceSoftwareUpdate() throws IOException {
1459 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1460 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1461 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1463 wireMockServer.stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]"
1464 + "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1465 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1466 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1467 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1469 // expected response
1470 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1471 RequestReferences requestReferences = new RequestReferences();
1472 requestReferences.setInstanceId("1882939");
1473 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1474 expectedResponse.setRequestReferences(requestReferences);
1475 uri = servInstanceuri + "v7"
1476 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1477 ResponseEntity<String> response =
1478 sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1480 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1481 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1482 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1486 public void deleteVfModuleInstance() throws IOException {
1487 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1488 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1489 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1492 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1493 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1495 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1496 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1498 wireMockServer.stubFor(get(urlMatching(
1499 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1500 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1501 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1502 .withBody(getWiremockResponseForCatalogdb(
1503 "vnfComponentRecipeDeleteVfModule_Response.json"))
1504 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1506 // expected response
1507 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1508 RequestReferences requestReferences = new RequestReferences();
1509 requestReferences.setInstanceId("1882939");
1510 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1511 expectedResponse.setRequestReferences(requestReferences);
1512 uri = servInstanceuri + "v7"
1513 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1514 ResponseEntity<String> response =
1515 sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1517 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1518 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1519 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1523 public void deleteVfModuleNoModelInvariantId() throws IOException {
1524 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1526 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1528 wireMockServer.stubFor(get(urlMatching(
1529 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1530 + "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1531 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1532 .withBody(getWiremockResponseForCatalogdb(
1533 "vnfComponentRecipeDeleteVfModule_Response.json"))
1534 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1536 // expected response
1537 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1538 RequestReferences requestReferences = new RequestReferences();
1539 requestReferences.setInstanceId("1882939");
1540 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1541 expectedResponse.setRequestReferences(requestReferences);
1542 uri = servInstanceuri + "v7"
1543 + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1544 ResponseEntity<String> response =
1545 sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1547 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1548 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1549 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1553 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1554 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1555 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1556 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1559 .stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]"
1560 + "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1561 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1562 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1563 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1565 wireMockServer.stubFor(get(urlMatching(
1566 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1567 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1568 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1569 .withBody(getWiremockResponseForCatalogdb(
1570 "vnfComponentRecipeDeactivate_Response.json"))
1571 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1573 // expected response
1574 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1575 RequestReferences requestReferences = new RequestReferences();
1576 requestReferences.setInstanceId("1882939");
1577 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1578 expectedResponse.setRequestReferences(requestReferences);
1579 uri = servInstanceuri + "v7"
1580 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1581 ResponseEntity<String> response =
1582 sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1584 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1585 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1586 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1590 public void createVolumeGroupInstance() throws IOException {
1591 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1592 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1593 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1595 wireMockServer.stubFor(get(urlMatching(
1596 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1597 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1598 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1599 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1601 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1602 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1603 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1604 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1606 wireMockServer.stubFor(get(urlMatching(
1607 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1608 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1609 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1610 .withBody(getWiremockResponseForCatalogdb(
1611 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1612 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1614 // expected response
1615 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1616 RequestReferences requestReferences = new RequestReferences();
1617 requestReferences.setInstanceId("1882939");
1618 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1619 expectedResponse.setRequestReferences(requestReferences);
1620 uri = servInstanceuri + "v7"
1621 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1622 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1624 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1625 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1626 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1627 assertTrue(response.getBody().contains("1882939"));
1631 public void updateVolumeGroupInstance() throws IOException {
1632 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1633 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1634 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1636 wireMockServer.stubFor(get(urlMatching(
1637 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1638 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1639 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1640 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1642 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1643 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1644 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1645 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1647 wireMockServer.stubFor(get(urlMatching(
1648 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1649 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1650 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1651 .withBody(getWiremockResponseForCatalogdb(
1652 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1653 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1655 // expected response
1656 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1657 RequestReferences requestReferences = new RequestReferences();
1658 requestReferences.setInstanceId("1882939");
1659 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1660 expectedResponse.setRequestReferences(requestReferences);
1661 uri = servInstanceuri + "v7"
1662 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1663 ResponseEntity<String> response =
1664 sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1666 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1667 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1668 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1672 public void deleteVolumeGroupInstance() throws IOException {
1673 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1674 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1675 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1677 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1678 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1679 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1681 wireMockServer.stubFor(get(urlMatching(
1682 ".*/vfModuleCustomization/search/findFirstByModelCustomizationUUIDOrderByCreatedDesc[?]MODEL_CUSTOMIZATION_UUID=b4ea86b4-253f-11e7-93ae-92361f002671"))
1683 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1684 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1685 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1687 wireMockServer.stubFor(get(urlMatching(".*/vfModuleCustomization/1/vfModule"))
1688 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1689 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1690 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1692 wireMockServer.stubFor(get(urlMatching(
1693 ".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction"
1694 + "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1695 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1696 .withBody(getWiremockResponseForCatalogdb(
1697 "vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1698 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1700 // expected response
1701 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1702 RequestReferences requestReferences = new RequestReferences();
1703 requestReferences.setInstanceId("1882939");
1704 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1705 expectedResponse.setRequestReferences(requestReferences);
1706 uri = servInstanceuri + "v7"
1707 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1708 ResponseEntity<String> response =
1709 sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1711 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1712 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1713 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1717 public void createNetworkInstance() throws IOException {
1718 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1719 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1720 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1722 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1723 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1724 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1725 .withStatus(HttpStatus.SC_OK)));
1727 wireMockServer.stubFor(
1728 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1729 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1730 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1731 .withStatus(HttpStatus.SC_OK)));
1733 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1734 + "modelName=GR-API-DEFAULT&action=createInstance"))
1735 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1736 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1737 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1739 // expected response
1740 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1741 RequestReferences requestReferences = new RequestReferences();
1742 requestReferences.setInstanceId("1882939");
1743 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1744 expectedResponse.setRequestReferences(requestReferences);
1745 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1746 ResponseEntity<String> response =
1747 sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1749 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1750 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1751 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1755 public void updateNetworkInstance() throws IOException {
1756 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1757 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1758 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1760 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1761 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1762 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1763 .withStatus(HttpStatus.SC_OK)));
1765 wireMockServer.stubFor(
1766 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1767 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1768 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1769 .withStatus(HttpStatus.SC_OK)));
1771 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1772 + "modelName=GR-API-DEFAULT&action=updateInstance"))
1773 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1774 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1775 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1776 // expected response
1777 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1778 RequestReferences requestReferences = new RequestReferences();
1779 requestReferences.setInstanceId("1882939");
1780 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1781 expectedResponse.setRequestReferences(requestReferences);
1782 uri = servInstanceuri + "v7"
1783 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1784 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1786 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1787 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1788 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1789 assertTrue(response.getBody().contains("1882939"));
1793 public void deleteNetworkInstance() throws IOException {
1794 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1795 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1796 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1798 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1799 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1800 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1801 .withStatus(HttpStatus.SC_OK)));
1803 wireMockServer.stubFor(
1804 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1805 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1806 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1807 .withStatus(HttpStatus.SC_OK)));
1809 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1810 + "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1812 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1813 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1815 // expected response
1816 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1817 RequestReferences requestReferences = new RequestReferences();
1818 requestReferences.setInstanceId("1882939");
1819 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1820 expectedResponse.setRequestReferences(requestReferences);
1821 uri = servInstanceuri + "v7"
1822 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1823 ResponseEntity<String> response =
1824 sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1826 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1827 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1828 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1832 public void deleteNetworkInstanceNoReqParams() throws IOException {
1833 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1834 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1835 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1837 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1838 + "modelName=GR-API-DEFAULT&action=deleteInstance"))
1839 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1840 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1841 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1844 // expected response
1845 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1846 RequestReferences requestReferences = new RequestReferences();
1847 requestReferences.setInstanceId("1882939");
1848 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1849 expectedResponse.setRequestReferences(requestReferences);
1850 uri = servInstanceuri + "v6"
1851 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1852 ResponseEntity<String> response =
1853 sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1855 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1856 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1857 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1861 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1863 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1864 expectedRecord.setRequestStatus("FAILED");
1865 expectedRecord.setStatusMessage("Error mapping request: ");
1866 expectedRecord.setProgress(100L);
1867 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1868 expectedRecord.setLastModifiedBy("APIH");
1869 expectedRecord.setRequestScope("network");
1870 expectedRecord.setRequestAction("deleteInstance");
1871 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1873 uri = servInstanceuri + "v6"
1874 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1875 ResponseEntity<String> response =
1876 sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1880 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1884 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1885 uri = servInstanceuri + "v5"
1886 + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1887 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1889 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1893 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1894 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1895 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1896 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1898 ServiceRecipe serviceRecipe = new ServiceRecipe();
1899 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1900 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1901 serviceRecipe.setAction(Action.createInstance.toString());
1902 serviceRecipe.setId(1);
1903 serviceRecipe.setRecipeTimeout(180);
1904 Service defaultService = new Service();
1905 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1907 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
1908 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1909 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
1911 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1912 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1913 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
1915 uri = servInstanceuri + "v7" + "/serviceInstances";
1916 ResponseEntity<String> response =
1917 sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1919 // expected response
1920 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1921 RequestReferences requestReferences = new RequestReferences();
1922 requestReferences.setInstanceId("1882939");
1923 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1924 expectedResponse.setRequestReferences(requestReferences);
1926 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1927 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1928 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1932 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1933 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1934 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1935 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1937 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1938 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1939 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1940 .withStatus(HttpStatus.SC_OK)));
1942 wireMockServer.stubFor(
1943 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1944 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1945 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1946 .withStatus(HttpStatus.SC_OK)));
1948 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
1949 + "modelName=GR-API-DEFAULT&action=createInstance"))
1950 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1951 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1952 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1954 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1955 ResponseEntity<String> response =
1956 sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1958 // expected response
1959 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1960 RequestReferences requestReferences = new RequestReferences();
1961 requestReferences.setInstanceId("1882939");
1962 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
1963 expectedResponse.setRequestReferences(requestReferences);
1965 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1966 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1967 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1971 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1972 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1973 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1974 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1976 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1977 ResponseEntity<String> response =
1978 sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1980 // expected response
1981 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1982 RequestReferences requestReferences = new RequestReferences();
1983 requestReferences.setInstanceId("1882939");
1984 expectedResponse.setRequestReferences(requestReferences);
1986 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1990 public void createNetworkInstanceTestApiGrApi() throws IOException {
1991 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1992 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1993 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1995 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1996 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1997 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1998 .withStatus(HttpStatus.SC_OK)));
2000 wireMockServer.stubFor(
2001 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2002 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2003 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2004 .withStatus(HttpStatus.SC_OK)));
2006 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2007 + "modelName=GR-API-DEFAULT&action=createInstance"))
2008 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2009 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2010 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2012 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2013 ResponseEntity<String> response =
2014 sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
2016 // expected response
2017 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2018 RequestReferences requestReferences = new RequestReferences();
2019 requestReferences.setInstanceId("1882939");
2020 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2021 expectedResponse.setRequestReferences(requestReferences);
2023 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2024 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2025 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2029 public void createNetworkInstanceTestApiVnfApi() throws IOException {
2030 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
2031 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2032 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2034 wireMockServer.stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2035 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2036 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
2037 .withStatus(HttpStatus.SC_OK)));
2039 wireMockServer.stubFor(
2040 get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
2041 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2042 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
2043 .withStatus(HttpStatus.SC_OK)));
2045 wireMockServer.stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]"
2046 + "modelName=VNF-API-DEFAULT&action=createInstance"))
2047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2048 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
2049 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2051 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
2052 ResponseEntity<String> response =
2053 sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
2055 // expected response
2056 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2057 RequestReferences requestReferences = new RequestReferences();
2058 requestReferences.setInstanceId("1882939");
2059 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2060 expectedResponse.setRequestReferences(requestReferences);
2062 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2063 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2064 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2068 public void activateServiceInstanceRequestStatus() throws IOException {
2069 ServiceRecipe serviceRecipe = new ServiceRecipe();
2070 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2071 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2072 serviceRecipe.setAction(Action.createInstance.toString());
2073 serviceRecipe.setId(1);
2074 serviceRecipe.setRecipeTimeout(180);
2075 Service defaultService = new Service();
2076 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2078 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2079 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2080 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2082 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2083 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2084 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2086 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2087 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2088 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2091 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2092 RequestReferences requestReferences = new RequestReferences();
2093 requestReferences.setInstanceId("1882939");
2094 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2095 expectedResponse.setRequestReferences(requestReferences);
2096 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2097 ResponseEntity<String> response =
2098 sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2100 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2101 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2102 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2106 public void invalidRequestId() throws IOException {
2107 String illegalRequestId = "1234";
2108 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
2109 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2110 uri = servInstanceuri + "v5/serviceInstances";
2111 ResponseEntity<String> response =
2112 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
2114 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2115 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2119 public void invalidBPELResponse() throws IOException {
2121 ServiceRecipe serviceRecipe = new ServiceRecipe();
2122 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2123 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2124 serviceRecipe.setAction(Action.createInstance.toString());
2125 serviceRecipe.setId(1);
2126 serviceRecipe.setRecipeTimeout(180);
2127 Service defaultService = new Service();
2128 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2130 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2131 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2132 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2134 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2135 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2136 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2138 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2139 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2140 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2142 uri = servInstanceuri + "v5/serviceInstances";
2143 ResponseEntity<String> response =
2144 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2146 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2147 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2148 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}",
2149 realResponse.getServiceException().getText());
2153 public void unauthorizedBPELResponse() throws IOException {
2155 ServiceRecipe serviceRecipe = new ServiceRecipe();
2156 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2157 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2158 serviceRecipe.setAction(Action.createInstance.toString());
2159 serviceRecipe.setId(1);
2160 serviceRecipe.setRecipeTimeout(180);
2161 Service defaultService = new Service();
2162 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2164 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2165 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2166 .withBodyFile("Camunda/UnauthorizedResponse.json")
2167 .withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2169 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2170 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2171 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2173 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2174 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2175 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2177 uri = servInstanceuri + "v5/serviceInstances";
2178 ResponseEntity<String> response =
2179 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2181 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2182 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2183 assertEquals("Exception caught mapping Camunda JSON response to object",
2184 realResponse.getServiceException().getText());
2188 public void invalidBPELResponse2() throws IOException {
2190 ServiceRecipe serviceRecipe = new ServiceRecipe();
2191 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2192 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2193 serviceRecipe.setAction(Action.createInstance.toString());
2194 serviceRecipe.setId(1);
2195 serviceRecipe.setRecipeTimeout(180);
2196 Service defaultService = new Service();
2197 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2199 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2200 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2201 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2203 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2204 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2205 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2207 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2208 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2209 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2210 uri = servInstanceuri + "v5/serviceInstances";
2211 ResponseEntity<String> response =
2212 sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2214 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2215 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2216 assertTrue(realResponse.getServiceException().getText()
2217 .contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2221 public void createMacroServiceInstance() throws IOException {
2222 ServiceRecipe serviceRecipe = new ServiceRecipe();
2223 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2224 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2225 serviceRecipe.setAction(Action.createInstance.toString());
2226 serviceRecipe.setId(1);
2227 serviceRecipe.setRecipeTimeout(180);
2228 Service defaultService = new Service();
2229 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2231 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2232 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2233 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2235 wireMockServer.stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")).willReturn(aResponse()
2236 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2237 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2239 wireMockServer.stubFor(get(urlMatching(".*/service/.*"))
2240 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2241 .withBody(mapper.writeValueAsString(defaultService)).withStatus(HttpStatus.SC_OK)));
2243 wireMockServer.stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2244 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2245 .withBody(mapper.writeValueAsString(serviceRecipe)).withStatus(HttpStatus.SC_OK)));
2248 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2249 RequestReferences requestReferences = new RequestReferences();
2250 requestReferences.setInstanceId("1882939");
2251 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5", "32807a28-1a14-4b88-b7b3-2950918aa76d"));
2252 expectedResponse.setRequestReferences(requestReferences);
2253 uri = servInstanceuri + "v5";
2254 ResponseEntity<String> response =
2255 sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2258 assertEquals(404, response.getStatusCode().value());
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.SOAuditLogContainerFilter")
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(ONAPLogConstants.MDCs.PARTNER_NAME));
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);