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.stubFor;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
29 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
30 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
31 import static org.junit.Assert.assertEquals;
32 import static org.junit.Assert.assertFalse;
33 import static org.junit.Assert.assertNotNull;
34 import static org.junit.Assert.assertThat;
35 import static org.junit.Assert.assertTrue;
38 import java.io.IOException;
39 import java.net.MalformedURLException;
41 import java.net.URISyntaxException;
43 import java.nio.file.Files;
44 import java.nio.file.Paths;
45 import java.util.List;
48 import javax.ws.rs.core.MediaType;
49 import javax.ws.rs.core.Response;
51 import org.apache.http.HttpStatus;
52 import org.junit.Before;
53 import org.junit.Ignore;
54 import org.junit.Test;
55 import org.onap.logging.ref.slf4j.ONAPLogConstants;
56 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
57 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
58 import org.onap.so.db.catalog.beans.Service;
59 import org.onap.so.db.catalog.beans.ServiceRecipe;
60 import org.onap.so.db.request.beans.InfraActiveRequests;
61 import org.onap.so.logger.LogConstants;
62 import org.onap.so.logger.MsoLogger;
63 import org.onap.so.serviceinstancebeans.CloudConfiguration;
64 import org.onap.so.serviceinstancebeans.ModelInfo;
65 import org.onap.so.serviceinstancebeans.RequestDetails;
66 import org.onap.so.serviceinstancebeans.RequestError;
67 import org.onap.so.serviceinstancebeans.RequestInfo;
68 import org.onap.so.serviceinstancebeans.RequestParameters;
69 import org.onap.so.serviceinstancebeans.RequestReferences;
70 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
71 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
72 import org.springframework.beans.factory.annotation.Autowired;
73 import org.springframework.beans.factory.annotation.Value;
74 import org.springframework.http.HttpEntity;
75 import org.springframework.http.HttpHeaders;
76 import org.springframework.http.HttpMethod;
77 import org.springframework.http.ResponseEntity;
78 import org.springframework.util.ResourceUtils;
79 import org.springframework.web.util.UriComponentsBuilder;
81 import com.fasterxml.jackson.annotation.JsonInclude.Include;
82 import com.fasterxml.jackson.core.JsonProcessingException;
83 import com.fasterxml.jackson.databind.DeserializationFeature;
84 import com.fasterxml.jackson.databind.ObjectMapper;
85 import com.github.tomakehurst.wiremock.http.Fault;
87 import ch.qos.logback.classic.spi.ILoggingEvent;
90 public class ServiceInstancesTest extends BaseTest{
92 private final ObjectMapper mapper = new ObjectMapper();
93 private ObjectMapper errorMapper = new ObjectMapper();
96 private ServiceInstances servInstances;
98 @Value("${wiremock.server.port}")
99 private String wiremockPort;
101 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
102 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
104 private URL selfLink;
105 private URL initialUrl;
106 private int initialPort;
107 private HttpHeaders headers;
110 public void beforeClass() {
111 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
112 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
113 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
115 headers = new HttpHeaders();
116 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
117 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
118 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
119 try { // generate one-time port number to avoid RANDOM port number later.
120 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
121 initialPort = initialUrl.getPort();
122 } catch (MalformedURLException e) {
125 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
127 .withStatus(HttpStatus.SC_OK)));
130 public String inputStream(String JsonInput)throws IOException{
131 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
132 return new String(Files.readAllBytes(Paths.get(JsonInput)));
135 private URL createExpectedSelfLink(String version, String requestId) {
136 System.out.println("createdUrl: " + initialUrl.toString());
138 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
139 } catch (MalformedURLException e) {
145 private String getWiremockResponseForCatalogdb(String file) {
147 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
148 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
149 } catch (IOException e) {
156 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
158 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
159 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
161 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
162 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
165 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
167 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
169 return restTemplate.exchange(builder.toUriString(),
170 reqMethod, request, String.class);
173 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
174 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
178 public void test_mapJSONtoMSOStyle() throws IOException{
179 ObjectMapper mapper = new ObjectMapper();
180 mapper.setSerializationInclusion(Include.NON_NULL);
181 String testRequest= inputStream("/ServiceInstanceDefault.json");
182 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
183 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
184 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
185 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
186 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
187 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
188 assertEquals("10",modelInfo.getModelUuid());
192 public void createServiceInstanceVIDDefault() throws IOException{
193 TestAppender.events.clear();
195 ServiceRecipe serviceRecipe = new ServiceRecipe();
196 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
197 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
198 serviceRecipe.setAction(Action.createInstance.toString());
199 serviceRecipe.setId(1);
200 serviceRecipe.setRecipeTimeout(180);
201 Service defaultService = new Service();
202 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
205 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
206 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
207 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
209 stubFor(get(urlMatching(".*/service/search/.*"))
210 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
211 .withBody(mapper.writeValueAsString(defaultService))
212 .withStatus(HttpStatus.SC_OK)));
214 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
215 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
216 .withBody(mapper.writeValueAsString(serviceRecipe))
217 .withStatus(HttpStatus.SC_OK)));
220 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
221 RequestReferences requestReferences = new RequestReferences();
222 requestReferences.setInstanceId("1882939");
223 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
224 expectedResponse.setRequestReferences(requestReferences);
225 uri = servInstanceuri + "v5/serviceInstances";
226 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
229 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
230 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
231 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
235 for(ILoggingEvent logEvent : TestAppender.events)
236 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
237 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
239 Map<String,String> mdc = logEvent.getMDCPropertyMap();
240 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
241 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
242 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
243 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
244 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
245 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
246 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
247 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
248 Map<String,String> mdc = logEvent.getMDCPropertyMap();
249 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
250 assertNotNull(mdc.get(MsoLogger.ENDTIME));
251 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
252 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
253 assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
254 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
255 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
256 assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
257 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
258 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
259 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
260 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
264 public void createServiceInstanceServiceInstancesUri() throws IOException{
265 ServiceRecipe serviceRecipe = new ServiceRecipe();
266 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
267 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
268 serviceRecipe.setAction(Action.createInstance.toString());
269 serviceRecipe.setId(1);
270 serviceRecipe.setRecipeTimeout(180);
271 Service defaultService = new Service();
272 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
274 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
275 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
276 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
279 stubFor(get(urlMatching(".*/service/search/.*"))
280 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
281 .withBody(mapper.writeValueAsString(defaultService))
282 .withStatus(HttpStatus.SC_OK)));
284 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
286 .withBody(mapper.writeValueAsString(serviceRecipe))
287 .withStatus(HttpStatus.SC_OK)));
289 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
290 RequestReferences requestReferences = new RequestReferences();
291 requestReferences.setInstanceId("1882939");
292 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
293 expectedResponse.setRequestReferences(requestReferences);
294 uri = servInstanceUriPrev7 + "v5";
295 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
298 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
299 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
300 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
303 public void createServiceInstanceBpelStatusError() throws IOException{
304 ServiceRecipe serviceRecipe = new ServiceRecipe();
305 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
306 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
307 serviceRecipe.setAction(Action.createInstance.toString());
308 serviceRecipe.setId(1);
309 serviceRecipe.setRecipeTimeout(180);
310 Service defaultService = new Service();
311 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
314 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
315 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
316 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
319 stubFor(get(urlMatching(".*/service/search/.*"))
320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
321 .withBody(mapper.writeValueAsString(defaultService))
322 .withStatus(HttpStatus.SC_OK)));
324 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
325 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
326 .withBody(mapper.writeValueAsString(serviceRecipe))
327 .withStatus(HttpStatus.SC_OK)));
329 uri = servInstanceuri + "v5/serviceInstances";
330 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
332 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
335 public void createServiceInstanceBadGateway() throws IOException{
336 ServiceRecipe serviceRecipe = new ServiceRecipe();
337 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
338 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
339 serviceRecipe.setAction(Action.createInstance.toString());
340 serviceRecipe.setId(1);
341 serviceRecipe.setRecipeTimeout(180);
342 Service defaultService = new Service();
343 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
345 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
346 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
348 stubFor(get(urlMatching(".*/service/search/.*"))
349 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
350 .withBody(mapper.writeValueAsString(defaultService))
351 .withStatus(HttpStatus.SC_OK)));
353 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
354 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
355 .withBody(mapper.writeValueAsString(serviceRecipe))
356 .withStatus(HttpStatus.SC_OK)));
358 uri = servInstanceuri + "v5/serviceInstances";
359 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
361 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
364 public void createServiceInstanceEmptyResponse() throws IOException{
365 ServiceRecipe serviceRecipe = new ServiceRecipe();
366 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
367 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
368 serviceRecipe.setAction(Action.createInstance.toString());
369 serviceRecipe.setId(1);
370 serviceRecipe.setRecipeTimeout(180);
371 Service defaultService = new Service();
372 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
374 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
375 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
377 stubFor(get(urlMatching(".*/service/search/.*"))
378 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
379 .withBody(mapper.writeValueAsString(defaultService))
380 .withStatus(HttpStatus.SC_OK)));
382 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
383 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
384 .withBody(mapper.writeValueAsString(serviceRecipe))
385 .withStatus(HttpStatus.SC_OK)));
387 uri = servInstanceuri + "v5/serviceInstances";
388 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
390 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
393 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
394 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
395 HttpHeaders requestIDheaders = new HttpHeaders();
396 requestIDheaders.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
397 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, requestIDheaders);
399 Service defaultService = new Service();
400 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
402 stubFor(get(urlMatching(".*/service/search/.*"))
403 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
404 .withBody(mapper.writeValueAsString(defaultService))
405 .withStatus(HttpStatus.SC_OK)));
408 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
409 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
410 .withStatus(HttpStatus.SC_NOT_FOUND)));
412 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
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 stubFor(get(urlMatching(".*/service/search/.*"))
420 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
421 .withBody(mapper.writeValueAsString(defaultService))
422 .withStatus(HttpStatus.SC_OK)));
424 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
425 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
426 .withStatus(HttpStatus.SC_NOT_FOUND)));
428 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
430 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 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 stubFor(get(urlMatching(".*/service/search/.*"))
448 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
449 .withBody(mapper.writeValueAsString(defaultService))
450 .withStatus(HttpStatus.SC_OK)));
452 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
453 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
454 .withBody(mapper.writeValueAsString(serviceRecipe))
455 .withStatus(HttpStatus.SC_OK)));
457 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
458 RequestReferences requestReferences = new RequestReferences();
459 requestReferences.setInstanceId("1882939");
460 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
461 expectedResponse.setRequestReferences(requestReferences);
462 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
463 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
465 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
466 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
467 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 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 stubFor(get(urlMatching(".*/service/.*"))
486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
487 .withBody(mapper.writeValueAsString(defaultService))
488 .withStatus(HttpStatus.SC_OK)));
490 stubFor(get(urlMatching(".*/service/search/.*"))
491 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
492 .withBody(mapper.writeValueAsString(defaultService))
493 .withStatus(HttpStatus.SC_OK)));
495 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
496 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
497 .withBody(mapper.writeValueAsString(serviceRecipe))
498 .withStatus(HttpStatus.SC_OK)));
501 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
502 RequestReferences requestReferences = new RequestReferences();
503 requestReferences.setInstanceId("1882939");
504 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
505 expectedResponse.setRequestReferences(requestReferences);
506 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
507 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
509 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
510 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
511 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
514 public void deleteServiceInstance() throws IOException {
515 ServiceRecipe serviceRecipe = new ServiceRecipe();
516 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
517 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
518 serviceRecipe.setAction(Action.createInstance.toString());
519 serviceRecipe.setId(1);
520 serviceRecipe.setRecipeTimeout(180);
521 Service defaultService = new Service();
522 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
524 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
526 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
528 stubFor(get(urlMatching(".*/service/.*"))
529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
530 .withBody(mapper.writeValueAsString(defaultService))
531 .withStatus(HttpStatus.SC_OK)));
533 stubFor(get(urlMatching(".*/service/search/.*"))
534 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
535 .withBody(mapper.writeValueAsString(defaultService))
536 .withStatus(HttpStatus.SC_OK)));
538 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
539 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
540 .withBody(mapper.writeValueAsString(serviceRecipe))
541 .withStatus(HttpStatus.SC_OK)));
543 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
544 RequestReferences requestReferences = new RequestReferences();
545 requestReferences.setInstanceId("1882939");
546 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
547 expectedResponse.setRequestReferences(requestReferences);
548 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
549 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
551 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
552 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
553 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
556 public void assignServiceInstance() throws IOException {
557 ServiceRecipe serviceRecipe = new ServiceRecipe();
558 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
559 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
560 serviceRecipe.setAction(Action.createInstance.toString());
561 serviceRecipe.setId(1);
562 serviceRecipe.setRecipeTimeout(180);
563 Service defaultService = new Service();
564 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
566 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
567 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
568 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
570 stubFor(get(urlMatching(".*/service/.*"))
571 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
572 .withBody(mapper.writeValueAsString(defaultService))
573 .withStatus(HttpStatus.SC_OK)));
575 stubFor(get(urlMatching(".*/service/search/.*"))
576 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
577 .withBody(mapper.writeValueAsString(defaultService))
578 .withStatus(HttpStatus.SC_OK)));
580 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
581 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
582 .withBody(mapper.writeValueAsString(serviceRecipe))
583 .withStatus(HttpStatus.SC_OK)));
585 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
586 RequestReferences requestReferences = new RequestReferences();
587 requestReferences.setInstanceId("1882939");
588 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
589 expectedResponse.setRequestReferences(requestReferences);
590 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
591 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
593 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
594 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
595 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
599 public void unassignServiceInstance() throws IOException {
600 ServiceRecipe serviceRecipe = new ServiceRecipe();
601 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
602 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
603 serviceRecipe.setAction(Action.createInstance.toString());
604 serviceRecipe.setId(1);
605 serviceRecipe.setRecipeTimeout(180);
606 Service defaultService = new Service();
607 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
609 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
610 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
611 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
613 stubFor(get(urlMatching(".*/service/.*"))
614 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
615 .withBody(mapper.writeValueAsString(defaultService))
616 .withStatus(HttpStatus.SC_OK)));
618 stubFor(get(urlMatching(".*/service/search/.*"))
619 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
620 .withBody(mapper.writeValueAsString(defaultService))
621 .withStatus(HttpStatus.SC_OK)));
623 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
624 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
625 .withBody(mapper.writeValueAsString(serviceRecipe))
626 .withStatus(HttpStatus.SC_OK)));
628 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
629 RequestReferences requestReferences = new RequestReferences();
630 requestReferences.setInstanceId("1882939");
631 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
632 expectedResponse.setRequestReferences(requestReferences);
633 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
634 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
636 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
637 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
638 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
641 public void createPortConfiguration() throws IOException {
642 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
643 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
644 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
646 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
647 RequestReferences requestReferences = new RequestReferences();
648 requestReferences.setInstanceId("1882939");
649 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
650 expectedResponse.setRequestReferences(requestReferences);
651 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
652 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
654 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
655 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
656 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
657 assertTrue(response.getBody().contains("1882939"));
660 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
661 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
662 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
664 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
667 public void deletePortConfiguration() throws IOException {
668 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
669 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
670 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
673 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
674 RequestReferences requestReferences = new RequestReferences();
675 requestReferences.setInstanceId("1882939");
676 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
677 expectedResponse.setRequestReferences(requestReferences);
678 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
679 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
681 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
682 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
683 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
686 public void enablePort() throws IOException {
687 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
688 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
689 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
691 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
692 RequestReferences requestReferences = new RequestReferences();
693 requestReferences.setInstanceId("1882939");
694 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
695 expectedResponse.setRequestReferences(requestReferences);
696 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
697 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
699 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
700 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
701 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
704 public void disablePort() throws IOException {
705 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
706 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
707 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
709 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
710 RequestReferences requestReferences = new RequestReferences();
711 requestReferences.setInstanceId("1882939");
712 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
713 expectedResponse.setRequestReferences(requestReferences);
714 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
715 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
717 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
718 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
719 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
722 public void activatePort() throws IOException {
723 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
724 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
725 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
727 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
728 RequestReferences requestReferences = new RequestReferences();
729 requestReferences.setInstanceId("1882939");
730 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
731 expectedResponse.setRequestReferences(requestReferences);
732 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
733 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
735 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
736 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
737 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
740 public void deactivatePort() throws IOException {
741 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
742 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
743 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
745 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
746 RequestReferences requestReferences = new RequestReferences();
747 requestReferences.setInstanceId("1882939");
748 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
749 expectedResponse.setRequestReferences(requestReferences);
750 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
751 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
753 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
754 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
755 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
758 public void addRelationships() throws IOException {
759 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
760 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
761 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
763 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
764 RequestReferences requestReferences = new RequestReferences();
765 requestReferences.setInstanceId("1882939");
766 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
767 expectedResponse.setRequestReferences(requestReferences);
768 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
769 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
771 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
772 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
773 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
776 public void removeRelationships() throws IOException {
777 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
778 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
779 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
781 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
782 RequestReferences requestReferences = new RequestReferences();
783 requestReferences.setInstanceId("1882939");
784 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
785 expectedResponse.setRequestReferences(requestReferences);
786 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
787 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
789 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
790 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
791 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
794 public void createVnfInstanceNoALaCarte() throws IOException {
795 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
796 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
797 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
800 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
801 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
802 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
803 .withStatus(org.apache.http.HttpStatus.SC_OK)));
805 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
806 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
807 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
808 .withStatus(org.apache.http.HttpStatus.SC_OK)));
810 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
812 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
813 .withStatus(org.apache.http.HttpStatus.SC_OK)));
816 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
817 RequestReferences requestReferences = new RequestReferences();
818 requestReferences.setInstanceId("1882939");
819 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
820 expectedResponse.setRequestReferences(requestReferences);
821 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
822 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
824 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
825 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
826 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
829 public void createVnfInstance() throws IOException {
830 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
831 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
832 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
834 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
835 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
836 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
837 .withStatus(org.apache.http.HttpStatus.SC_OK)));
838 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
839 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
840 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
841 .withStatus(org.apache.http.HttpStatus.SC_OK)));
844 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
846 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
847 .withStatus(org.apache.http.HttpStatus.SC_OK)));
849 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
850 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
851 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
852 .withStatus(org.apache.http.HttpStatus.SC_OK)));
855 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
856 RequestReferences requestReferences = new RequestReferences();
857 requestReferences.setInstanceId("1882939");
858 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
859 expectedResponse.setRequestReferences(requestReferences);
860 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
861 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
863 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
864 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
865 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
866 assertTrue(response.getBody().contains("1882939"));
869 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
870 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
871 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
873 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
876 public void createVnfInstanceInvalidVnfResource() throws IOException {
877 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
878 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
880 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
881 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
882 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
885 public void replaceVnfInstance() throws IOException {
886 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
887 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
888 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
890 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
891 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
892 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
893 .withStatus(org.apache.http.HttpStatus.SC_OK)));
895 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
896 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
897 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
898 .withStatus(org.apache.http.HttpStatus.SC_OK)));
900 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
901 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
902 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
903 .withStatus(org.apache.http.HttpStatus.SC_OK)));
905 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
906 RequestReferences requestReferences = new RequestReferences();
907 requestReferences.setInstanceId("1882939");
908 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
909 expectedResponse.setRequestReferences(requestReferences);
910 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
911 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
913 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
914 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
915 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
918 public void replaceVnfRecreateInstance() throws IOException {
919 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
920 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
921 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
923 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
924 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
925 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
926 .withStatus(org.apache.http.HttpStatus.SC_OK)));
928 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
929 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
930 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
931 .withStatus(org.apache.http.HttpStatus.SC_OK)));
933 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
934 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
935 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
936 .withStatus(org.apache.http.HttpStatus.SC_OK)));
939 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
940 RequestReferences requestReferences = new RequestReferences();
941 requestReferences.setInstanceId("1882939");
942 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
943 expectedResponse.setRequestReferences(requestReferences);
944 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
945 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
946 logger.debug(response.getBody());
948 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
949 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
950 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
953 public void recreateVnfInstance() throws IOException {
954 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
955 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
956 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
958 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
959 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
960 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
961 .withStatus(org.apache.http.HttpStatus.SC_OK)));
963 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
964 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
965 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
966 .withStatus(org.apache.http.HttpStatus.SC_OK)));
968 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
969 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
970 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
971 .withStatus(org.apache.http.HttpStatus.SC_OK)));
974 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
975 RequestReferences requestReferences = new RequestReferences();
976 requestReferences.setInstanceId("1882939");
977 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
978 expectedResponse.setRequestReferences(requestReferences);
979 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
980 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
981 logger.debug(response.getBody());
983 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
984 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
985 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
988 public void updateVnfInstance() throws IOException {
989 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
990 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
991 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
993 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
994 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
995 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
996 .withStatus(org.apache.http.HttpStatus.SC_OK)));
998 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
999 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1000 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1001 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1003 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1004 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1005 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1006 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1007 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1010 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1011 RequestReferences requestReferences = new RequestReferences();
1012 requestReferences.setInstanceId("1882939");
1013 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1014 expectedResponse.setRequestReferences(requestReferences);
1015 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1016 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1018 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1019 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1020 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1023 public void applyUpdatedConfig() throws IOException {
1024 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1025 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1026 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1029 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1030 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1031 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1032 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1033 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1036 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1037 RequestReferences requestReferences = new RequestReferences();
1038 requestReferences.setInstanceId("1882939");
1039 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1040 expectedResponse.setRequestReferences(requestReferences);
1041 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1042 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1044 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1045 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1046 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1049 public void deleteVnfInstanceV5() throws IOException {
1050 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1051 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1052 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1054 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1055 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1056 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1057 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1058 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1060 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1061 RequestReferences requestReferences = new RequestReferences();
1062 requestReferences.setInstanceId("1882939");
1063 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1064 expectedResponse.setRequestReferences(requestReferences);
1065 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1066 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1068 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1069 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1070 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1073 public void createVfModuleInstance() throws IOException {
1074 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1076 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1077 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1079 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1081 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1082 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1084 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1085 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1086 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1087 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1089 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1090 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1091 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1093 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1094 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1095 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1096 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1097 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1099 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1100 RequestReferences requestReferences = new RequestReferences();
1101 requestReferences.setInstanceId("1882939");
1102 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1103 expectedResponse.setRequestReferences(requestReferences);
1104 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1105 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1107 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1108 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1109 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1110 assertTrue(response.getBody().contains("1882939"));
1113 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1114 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1115 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1116 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1118 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1119 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1120 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1121 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1123 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1124 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1125 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1126 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1127 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1129 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1130 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1131 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1132 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1134 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1135 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1136 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1137 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1138 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1140 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1141 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1142 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1143 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1145 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1146 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1147 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1148 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1151 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1152 "[?]vnfComponentType=vfModule&action=createInstance"))
1153 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1154 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1155 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1158 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1159 RequestReferences requestReferences = new RequestReferences();
1160 requestReferences.setInstanceId("1882939");
1161 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1162 expectedResponse.setRequestReferences(requestReferences);
1163 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1164 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1165 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1166 ObjectMapper mapper = new ObjectMapper();
1167 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1168 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1171 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1172 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1173 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1174 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1176 stubFor(get(urlMatching(".*/vnfResource/.*"))
1177 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1178 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1179 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1181 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1182 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1183 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1184 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1186 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1187 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1188 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1189 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1191 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1192 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1193 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1194 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1196 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1197 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1198 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1199 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1201 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1202 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1203 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1204 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1206 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1207 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1208 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1209 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1210 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1213 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1214 RequestReferences requestReferences = new RequestReferences();
1215 requestReferences.setInstanceId("1882939");
1216 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1217 expectedResponse.setRequestReferences(requestReferences);
1218 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1219 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1222 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1223 ObjectMapper mapper = new ObjectMapper();
1224 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1225 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1228 public void createVfModuleInstanceNoRecipe() throws IOException {
1230 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1231 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1232 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1233 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1235 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1236 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1237 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1238 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1239 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1241 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1242 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1243 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1244 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1246 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1247 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1248 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1249 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1250 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1252 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1253 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1255 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1256 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1257 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1260 public void replaceVfModuleInstance() throws IOException {
1261 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1262 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1263 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1265 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1266 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1267 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1268 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1269 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1271 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1272 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1273 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1274 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1275 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1277 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1278 RequestReferences requestReferences = new RequestReferences();
1279 requestReferences.setInstanceId("1882939");
1280 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1281 expectedResponse.setRequestReferences(requestReferences);
1282 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1283 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1285 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1286 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1287 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1290 public void updateVfModuleInstance() throws IOException {
1291 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1292 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1293 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1295 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1296 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1297 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1298 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1300 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1301 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1302 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1303 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1305 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1306 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1307 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1308 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1310 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1311 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1312 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1313 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1314 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1317 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1318 RequestReferences requestReferences = new RequestReferences();
1319 requestReferences.setInstanceId("1882939");
1320 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1321 expectedResponse.setRequestReferences(requestReferences);
1322 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1323 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1324 logger.debug(response.getBody());
1326 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1327 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1328 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1331 public void createVfModuleNoModelType() throws IOException{
1332 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1333 expectedRecord.setRequestStatus("FAILED");
1334 expectedRecord.setAction("createInstance");
1335 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1336 expectedRecord.setProgress(100L);
1337 expectedRecord.setSource("VID");
1338 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1339 expectedRecord.setLastModifiedBy("APIH");
1340 expectedRecord.setVfModuleName("testVfModule2");
1341 expectedRecord.setVfModuleModelName("serviceModel");
1342 expectedRecord.setRequestScope("vfModule");
1343 expectedRecord.setRequestAction("createInstance");
1344 expectedRecord.setRequestorId("zz9999");
1345 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1346 //VnfType is not sent in this request, should be blank in db
1347 expectedRecord.setVnfType("");
1348 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1350 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1352 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1355 public void inPlaceSoftwareUpdate() throws IOException {
1356 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1357 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1358 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1360 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1361 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1362 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1363 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1364 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1367 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1368 RequestReferences requestReferences = new RequestReferences();
1369 requestReferences.setInstanceId("1882939");
1370 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1371 expectedResponse.setRequestReferences(requestReferences);
1372 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1373 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1375 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1376 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1377 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1381 public void deleteVfModuleInstance() throws IOException {
1382 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1383 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1384 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1386 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1387 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1388 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1389 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1390 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1392 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1393 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1394 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1395 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1396 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1399 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1400 RequestReferences requestReferences = new RequestReferences();
1401 requestReferences.setInstanceId("1882939");
1402 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1403 expectedResponse.setRequestReferences(requestReferences);
1404 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1405 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1407 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1408 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1409 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1412 public void deleteVfModuleNoModelInvariantId() throws IOException {
1413 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1414 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1415 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1417 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1418 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1419 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1420 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1421 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1424 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1425 RequestReferences requestReferences = new RequestReferences();
1426 requestReferences.setInstanceId("1882939");
1427 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1428 expectedResponse.setRequestReferences(requestReferences);
1429 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1430 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1432 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1433 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1434 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1437 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1438 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1439 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1440 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1442 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1443 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1445 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1446 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1448 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1449 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1450 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1451 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1452 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1455 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1456 RequestReferences requestReferences = new RequestReferences();
1457 requestReferences.setInstanceId("1882939");
1458 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1459 expectedResponse.setRequestReferences(requestReferences);
1460 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1461 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1463 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1464 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1465 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1468 public void createVolumeGroupInstance() throws IOException {
1469 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1470 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1471 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1473 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1474 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1475 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1476 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1478 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1479 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1480 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1481 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1483 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1484 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1485 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1486 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1487 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1490 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1491 RequestReferences requestReferences = new RequestReferences();
1492 requestReferences.setInstanceId("1882939");
1493 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1494 expectedResponse.setRequestReferences(requestReferences);
1495 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1496 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1498 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1499 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1500 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1501 assertTrue(response.getBody().contains("1882939"));
1504 public void updateVolumeGroupInstance() throws IOException {
1505 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1507 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1509 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1510 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1511 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1512 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1514 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1515 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1516 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1517 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1519 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1520 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1522 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1523 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1526 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1527 RequestReferences requestReferences = new RequestReferences();
1528 requestReferences.setInstanceId("1882939");
1529 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1530 expectedResponse.setRequestReferences(requestReferences);
1531 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1532 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1534 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1535 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1536 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1539 public void deleteVolumeGroupInstance() throws IOException {
1540 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1541 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1542 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1544 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1545 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1546 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1548 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1549 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1550 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1551 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1553 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1554 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1555 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1556 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1558 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1559 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1560 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1561 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1562 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1565 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1566 RequestReferences requestReferences = new RequestReferences();
1567 requestReferences.setInstanceId("1882939");
1568 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1569 expectedResponse.setRequestReferences(requestReferences);
1570 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1571 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1573 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1574 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1575 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1578 public void createNetworkInstance() throws IOException {
1579 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1580 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1581 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1583 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1584 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1585 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1586 .withStatus(HttpStatus.SC_OK)));
1588 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1589 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1590 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1591 .withStatus(HttpStatus.SC_OK)));
1593 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1594 "modelName=GR-API-DEFAULT&action=createInstance"))
1595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1596 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1597 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1600 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1601 RequestReferences requestReferences = new RequestReferences();
1602 requestReferences.setInstanceId("1882939");
1603 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1604 expectedResponse.setRequestReferences(requestReferences);
1605 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1606 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1608 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1609 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1610 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1613 public void updateNetworkInstance() throws IOException {
1614 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1615 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1616 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1618 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1619 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1620 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1621 .withStatus(HttpStatus.SC_OK)));
1623 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1624 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1625 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1626 .withStatus(HttpStatus.SC_OK)));
1628 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1629 "modelName=GR-API-DEFAULT&action=updateInstance"))
1630 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1631 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1632 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1634 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1635 RequestReferences requestReferences = new RequestReferences();
1636 requestReferences.setInstanceId("1882939");
1637 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1638 expectedResponse.setRequestReferences(requestReferences);
1639 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1640 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1642 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1643 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1644 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1645 assertTrue(response.getBody().contains("1882939"));
1648 public void deleteNetworkInstance() throws IOException {
1649 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1650 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1651 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1653 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1654 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1655 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1656 .withStatus(HttpStatus.SC_OK)));
1658 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1659 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1660 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1661 .withStatus(HttpStatus.SC_OK)));
1663 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1664 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1665 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1666 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1667 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1670 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1671 RequestReferences requestReferences = new RequestReferences();
1672 requestReferences.setInstanceId("1882939");
1673 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1674 expectedResponse.setRequestReferences(requestReferences);
1675 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1676 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1678 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1679 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1680 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1683 public void deleteNetworkInstanceNoReqParams() throws IOException {
1684 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1685 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1686 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1688 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1689 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1690 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1691 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1692 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1696 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1697 RequestReferences requestReferences = new RequestReferences();
1698 requestReferences.setInstanceId("1882939");
1699 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1700 expectedResponse.setRequestReferences(requestReferences);
1701 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1702 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1704 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1705 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1706 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1709 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1711 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1712 expectedRecord.setRequestStatus("FAILED");
1713 expectedRecord.setStatusMessage("Error mapping request: ");
1714 expectedRecord.setProgress(100L);
1715 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1716 expectedRecord.setLastModifiedBy("APIH");
1717 expectedRecord.setRequestScope("network");
1718 expectedRecord.setRequestAction("deleteInstance");
1719 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1721 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1722 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1726 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1729 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1730 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1731 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1733 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1737 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1738 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1739 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1740 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1742 ServiceRecipe serviceRecipe = new ServiceRecipe();
1743 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1744 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1745 serviceRecipe.setAction(Action.createInstance.toString());
1746 serviceRecipe.setId(1);
1747 serviceRecipe.setRecipeTimeout(180);
1748 Service defaultService = new Service();
1749 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1751 stubFor(get(urlMatching(".*/service/.*"))
1752 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1753 .withBody(mapper.writeValueAsString(defaultService))
1754 .withStatus(HttpStatus.SC_OK)));
1756 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1757 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1758 .withBody(mapper.writeValueAsString(serviceRecipe))
1759 .withStatus(HttpStatus.SC_OK)));
1761 uri = servInstanceuri + "v7" + "/serviceInstances";
1762 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1765 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1766 RequestReferences requestReferences = new RequestReferences();
1767 requestReferences.setInstanceId("1882939");
1768 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1769 expectedResponse.setRequestReferences(requestReferences);
1771 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1772 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1773 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1777 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1778 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1779 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1780 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1782 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1783 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1784 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1785 .withStatus(HttpStatus.SC_OK)));
1787 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1788 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1789 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1790 .withStatus(HttpStatus.SC_OK)));
1792 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1793 "modelName=GR-API-DEFAULT&action=createInstance"))
1794 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1795 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1796 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1798 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1799 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1802 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1803 RequestReferences requestReferences = new RequestReferences();
1804 requestReferences.setInstanceId("1882939");
1805 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1806 expectedResponse.setRequestReferences(requestReferences);
1808 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1809 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1810 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1814 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1815 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1816 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1817 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1819 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1820 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1823 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1824 RequestReferences requestReferences = new RequestReferences();
1825 requestReferences.setInstanceId("1882939");
1826 expectedResponse.setRequestReferences(requestReferences);
1828 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1832 public void createNetworkInstanceTestApiGrApi() throws IOException {
1833 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 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1838 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1839 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1840 .withStatus(HttpStatus.SC_OK)));
1842 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1843 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1844 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1845 .withStatus(HttpStatus.SC_OK)));
1847 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1848 "modelName=GR-API-DEFAULT&action=createInstance"))
1849 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1850 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1851 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1853 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1854 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
1857 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1858 RequestReferences requestReferences = new RequestReferences();
1859 requestReferences.setInstanceId("1882939");
1860 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1861 expectedResponse.setRequestReferences(requestReferences);
1863 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1864 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1865 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1869 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1870 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1871 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1872 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1874 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1875 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1876 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1877 .withStatus(HttpStatus.SC_OK)));
1879 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1880 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1881 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1882 .withStatus(HttpStatus.SC_OK)));
1884 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1885 "modelName=VNF-API-DEFAULT&action=createInstance"))
1886 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1887 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1888 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1890 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1891 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
1894 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1895 RequestReferences requestReferences = new RequestReferences();
1896 requestReferences.setInstanceId("1882939");
1897 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1898 expectedResponse.setRequestReferences(requestReferences);
1900 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1901 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1902 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1906 public void activateServiceInstanceRequestStatus() throws IOException{
1907 ServiceRecipe serviceRecipe = new ServiceRecipe();
1908 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1909 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1910 serviceRecipe.setAction(Action.createInstance.toString());
1911 serviceRecipe.setId(1);
1912 serviceRecipe.setRecipeTimeout(180);
1913 Service defaultService = new Service();
1914 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1916 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1917 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1918 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1920 stubFor(get(urlMatching(".*/service/.*"))
1921 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1922 .withBody(mapper.writeValueAsString(defaultService))
1923 .withStatus(HttpStatus.SC_OK)));
1925 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1926 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1927 .withBody(mapper.writeValueAsString(serviceRecipe))
1928 .withStatus(HttpStatus.SC_OK)));
1931 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1932 RequestReferences requestReferences = new RequestReferences();
1933 requestReferences.setInstanceId("1882939");
1934 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1935 expectedResponse.setRequestReferences(requestReferences);
1936 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
1937 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
1939 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1940 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1941 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1945 public void invalidRequestId() throws IOException {
1946 String illegalRequestId = "1234";
1947 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
1948 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
1949 uri = servInstanceuri + "v5/serviceInstances";
1950 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
1952 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1953 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
1956 public void invalidBPELResponse() throws IOException{
1958 ServiceRecipe serviceRecipe = new ServiceRecipe();
1959 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1960 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1961 serviceRecipe.setAction(Action.createInstance.toString());
1962 serviceRecipe.setId(1);
1963 serviceRecipe.setRecipeTimeout(180);
1964 Service defaultService = new Service();
1965 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1967 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1968 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1969 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1971 stubFor(get(urlMatching(".*/service/.*"))
1972 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1973 .withBody(mapper.writeValueAsString(defaultService))
1974 .withStatus(HttpStatus.SC_OK)));
1976 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1977 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1978 .withBody(mapper.writeValueAsString(serviceRecipe))
1979 .withStatus(HttpStatus.SC_OK)));
1981 uri = servInstanceuri + "v5/serviceInstances";
1982 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
1984 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1985 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1986 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
1989 public void unauthorizedBPELResponse() throws IOException{
1991 ServiceRecipe serviceRecipe = new ServiceRecipe();
1992 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1993 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1994 serviceRecipe.setAction(Action.createInstance.toString());
1995 serviceRecipe.setId(1);
1996 serviceRecipe.setRecipeTimeout(180);
1997 Service defaultService = new Service();
1998 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2000 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2001 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2002 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2004 stubFor(get(urlMatching(".*/service/.*"))
2005 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2006 .withBody(mapper.writeValueAsString(defaultService))
2007 .withStatus(HttpStatus.SC_OK)));
2009 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2010 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2011 .withBody(mapper.writeValueAsString(serviceRecipe))
2012 .withStatus(HttpStatus.SC_OK)));
2014 uri = servInstanceuri + "v5/serviceInstances";
2015 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2017 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2018 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2019 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2023 public void invalidBPELResponse2() throws IOException{
2025 ServiceRecipe serviceRecipe = new ServiceRecipe();
2026 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2027 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2028 serviceRecipe.setAction(Action.createInstance.toString());
2029 serviceRecipe.setId(1);
2030 serviceRecipe.setRecipeTimeout(180);
2031 Service defaultService = new Service();
2032 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2034 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2035 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2036 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2038 stubFor(get(urlMatching(".*/service/.*"))
2039 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2040 .withBody(mapper.writeValueAsString(defaultService))
2041 .withStatus(HttpStatus.SC_OK)));
2043 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2044 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2045 .withBody(mapper.writeValueAsString(serviceRecipe))
2046 .withStatus(HttpStatus.SC_OK)));
2047 uri = servInstanceuri + "v5/serviceInstances";
2048 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2050 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2051 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2052 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2056 public void createMacroServiceInstance() throws IOException{
2057 ServiceRecipe serviceRecipe = new ServiceRecipe();
2058 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2059 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2060 serviceRecipe.setAction(Action.createInstance.toString());
2061 serviceRecipe.setId(1);
2062 serviceRecipe.setRecipeTimeout(180);
2063 Service defaultService = new Service();
2064 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2066 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2067 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2068 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2070 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2071 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2072 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2074 stubFor(get(urlMatching(".*/service/.*"))
2075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2076 .withBody(mapper.writeValueAsString(defaultService))
2077 .withStatus(HttpStatus.SC_OK)));
2079 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2081 .withBody(mapper.writeValueAsString(serviceRecipe))
2082 .withStatus(HttpStatus.SC_OK)));
2085 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2086 RequestReferences requestReferences = new RequestReferences();
2087 requestReferences.setInstanceId("1882939");
2088 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2089 expectedResponse.setRequestReferences(requestReferences);
2090 uri = servInstanceUriPrev7 + "v5";
2091 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2094 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2095 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2096 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2100 public void testUserParams() throws IOException {
2101 ObjectMapper mapper = new ObjectMapper();
2102 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2103 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2104 String userParamsTxt = inputStream("/userParams.txt");
2106 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2107 System.out.println(userParams);
2108 assertTrue(userParams.size() > 0);
2109 assertTrue(userParams.get(0).containsKey("name"));
2110 assertTrue(userParams.get(0).containsKey("value"));
2111 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2115 public void testConfigureCloudConfig() throws IOException {
2116 ObjectMapper mapper = new ObjectMapper();
2117 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2118 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2120 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2121 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2125 public void testMapToLegacyRequest() throws IOException {
2126 ObjectMapper mapper = new ObjectMapper();
2127 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2128 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2129 servInstances.mapToLegacyRequest(request.getRequestDetails());
2130 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2131 assertThat(request, sameBeanAs(expected));
2134 public void scaleOutVfModule() throws IOException {
2135 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2136 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2137 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2139 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2140 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2141 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2142 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2144 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2145 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2146 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2147 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2149 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2150 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2151 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2152 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2155 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2156 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2157 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2158 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2160 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2161 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2162 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2165 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2166 RequestReferences requestReferences = new RequestReferences();
2167 requestReferences.setInstanceId("1882939");
2168 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2169 expectedResponse.setRequestReferences(requestReferences);
2170 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2171 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2173 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2174 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2175 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2176 assertTrue(response.getBody().contains("1882939"));
2179 public void createServiceInstanceBadResponse() throws IOException{
2180 ServiceRecipe serviceRecipe = new ServiceRecipe();
2181 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2182 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2183 serviceRecipe.setAction(Action.createInstance.toString());
2184 serviceRecipe.setId(1);
2185 serviceRecipe.setRecipeTimeout(180);
2186 Service defaultService = new Service();
2187 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2189 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2190 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2191 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2193 stubFor(get(urlMatching(".*/service/.*"))
2194 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2195 .withBody(mapper.writeValueAsString(defaultService))
2196 .withStatus(HttpStatus.SC_OK)));
2198 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2199 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2200 .withBody(mapper.writeValueAsString(serviceRecipe))
2201 .withStatus(HttpStatus.SC_OK)));
2203 uri = servInstanceuri + "v5/serviceInstances";
2204 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2206 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2207 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2208 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2211 public void createServiceInstanceDuplicateError() throws IOException{
2212 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2213 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2214 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2216 uri = servInstanceuri + "v5/serviceInstances";
2217 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2219 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2220 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2221 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2224 public void createServiceInstanceDuplicateHistoryCheck() throws IOException{
2225 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2226 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2227 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2228 .withStatus(HttpStatus.SC_ACCEPTED)));
2229 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2230 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2231 .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2233 uri = servInstanceuri + "v5/serviceInstances";
2234 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2236 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2237 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2238 assertEquals("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.", realResponse.getServiceException().getText());
2241 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException{
2242 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2244 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2245 .withStatus(HttpStatus.SC_ACCEPTED)));
2246 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2247 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2248 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2250 uri = servInstanceuri + "v5/serviceInstances";
2251 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2253 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2254 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2255 assertEquals("Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2258 public void createServiceInstanceDuplicate() throws IOException{
2259 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2260 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2261 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2263 uri = servInstanceuri + "v5/serviceInstances";
2264 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2266 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2267 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2268 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2272 public void createServiceInstanceSaveError() throws IOException{
2273 ServiceRecipe serviceRecipe = new ServiceRecipe();
2274 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2275 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2276 serviceRecipe.setAction(Action.createInstance.toString());
2277 serviceRecipe.setId(1);
2278 serviceRecipe.setRecipeTimeout(180);
2279 Service defaultService = new Service();
2280 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2281 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2282 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2283 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2284 stubFor(get(urlMatching(".*/service/.*"))
2285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2286 .withBody(mapper.writeValueAsString(defaultService))
2287 .withStatus(HttpStatus.SC_OK)));
2289 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2290 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2291 .withBody(mapper.writeValueAsString(serviceRecipe))
2292 .withStatus(HttpStatus.SC_OK)));
2294 uri = servInstanceuri + "v5/serviceInstances";
2295 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2297 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2298 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2299 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2302 public void createPortConfigurationSaveError() throws IOException {
2303 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2304 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2305 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2306 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2307 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2308 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2310 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2311 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2313 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2314 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2315 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2318 public void createPortConfigDbUpdateError() throws IOException {
2319 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2321 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2323 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2324 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2326 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2327 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2328 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2331 public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
2332 TestAppender.events.clear();
2333 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2335 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2337 stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2339 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2340 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2342 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
2343 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2344 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2345 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2347 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
2348 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2349 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2350 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2351 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2352 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2354 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2355 RequestReferences requestReferences = new RequestReferences();
2356 requestReferences.setInstanceId("1882939");
2357 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2358 expectedResponse.setRequestReferences(requestReferences);
2359 uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2360 ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2362 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2363 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2364 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2365 assertEquals(response.getHeaders().get(MsoLogger.TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2367 for(ILoggingEvent logEvent : TestAppender.events){
2368 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging") &&
2369 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")){
2370 Map<String,String> mdc = logEvent.getMDCPropertyMap();
2371 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2376 public void createInstanceGroup() throws IOException{
2377 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2378 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2379 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2382 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2383 RequestReferences requestReferences = new RequestReferences();
2384 requestReferences.setInstanceId("1882939");
2385 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2386 expectedResponse.setRequestReferences(requestReferences);
2387 uri = servInstanceuri + "/v7/instanceGroups";
2388 ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2391 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2392 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2393 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2396 public void deleteInstanceGroup() throws IOException{
2397 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2398 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2399 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2402 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2403 RequestReferences requestReferences = new RequestReferences();
2404 requestReferences.setInstanceId("1882939");
2405 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2406 expectedResponse.setRequestReferences(requestReferences);
2407 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2408 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2411 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2412 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2413 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2416 public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
2417 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2418 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2420 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2421 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2422 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2425 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
2426 HttpHeaders noPartnerHeaders = new HttpHeaders();
2427 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2428 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2429 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2431 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2432 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2433 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2436 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException{
2437 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2438 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2439 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2441 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2442 RequestReferences requestReferences = new RequestReferences();
2443 requestReferences.setInstanceId("1882939");
2444 expectedResponse.setRequestReferences(requestReferences);
2445 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2446 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2449 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2450 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2451 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2454 public void addMembers() throws IOException{
2455 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2456 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2457 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2459 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2460 RequestReferences requestReferences = new RequestReferences();
2461 requestReferences.setInstanceId("1882939");
2462 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2463 expectedResponse.setRequestReferences(requestReferences);
2464 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2465 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2468 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2469 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2470 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2473 public void removeMembers() throws IOException{
2474 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2476 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2478 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2479 RequestReferences requestReferences = new RequestReferences();
2480 requestReferences.setInstanceId("1882939");
2481 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2482 expectedResponse.setRequestReferences(requestReferences);
2483 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2484 ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2487 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2488 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2489 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2492 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2493 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2495 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2497 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2498 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2499 .withStatus(HttpStatus.SC_NOT_FOUND)));
2501 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
2502 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2503 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2504 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2505 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2508 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2509 RequestReferences requestReferences = new RequestReferences();
2510 requestReferences.setInstanceId("1882939");
2511 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2512 expectedResponse.setRequestReferences(requestReferences);
2513 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2514 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2516 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2517 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2518 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2521 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2522 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2523 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2524 .withStatus(HttpStatus.SC_NOT_FOUND)));
2526 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2527 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2529 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2530 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2531 assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2535 public void setServiceTypeTestALaCarte() throws JsonProcessingException{
2536 String requestScope = ModelType.service.toString();
2537 Boolean aLaCarteFlag = true;
2538 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2539 RequestDetails requestDetails = new RequestDetails();
2540 RequestInfo requestInfo = new RequestInfo();
2541 requestInfo.setSource("VID");
2542 requestDetails.setRequestInfo(requestInfo);
2543 sir.setRequestDetails(requestDetails);
2544 Service defaultService = new Service();
2545 defaultService.setServiceType("testServiceTypeALaCarte");
2547 stubFor(get(urlMatching(".*/service/search/.*"))
2548 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2549 .withBody(mapper.writeValueAsString(defaultService))
2550 .withStatus(HttpStatus.SC_OK)));
2552 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2553 assertEquals(serviceType, "testServiceTypeALaCarte");
2556 public void setServiceTypeTest() throws JsonProcessingException{
2557 String requestScope = ModelType.service.toString();
2558 Boolean aLaCarteFlag = false;
2559 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2560 RequestDetails requestDetails = new RequestDetails();
2561 RequestInfo requestInfo = new RequestInfo();
2562 ModelInfo modelInfo = new ModelInfo();
2563 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2564 requestInfo.setSource("VID");
2565 requestDetails.setModelInfo(modelInfo);
2566 requestDetails.setRequestInfo(requestInfo);
2567 sir.setRequestDetails(requestDetails);
2568 Service defaultService = new Service();
2569 defaultService.setServiceType("testServiceType");
2571 stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2572 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2573 .withBody(mapper.writeValueAsString(defaultService))
2574 .withStatus(HttpStatus.SC_OK)));
2576 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2577 assertEquals(serviceType, "testServiceType");
2580 public void setServiceTypeTestDefault() throws JsonProcessingException{
2581 String requestScope = ModelType.service.toString();
2582 Boolean aLaCarteFlag = false;
2583 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2584 RequestDetails requestDetails = new RequestDetails();
2585 RequestInfo requestInfo = new RequestInfo();
2586 ModelInfo modelInfo = new ModelInfo();
2587 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2588 requestInfo.setSource("VID");
2589 requestDetails.setModelInfo(modelInfo);
2590 requestDetails.setRequestInfo(requestInfo);
2591 sir.setRequestDetails(requestDetails);
2592 Service defaultService = new Service();
2593 defaultService.setServiceType("testServiceType");
2595 stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2596 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2597 .withStatus(HttpStatus.SC_NOT_FOUND)));
2598 stubFor(get(urlMatching(".*/service/search/.*"))
2599 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2600 .withBody(mapper.writeValueAsString(defaultService))
2601 .withStatus(HttpStatus.SC_OK)));
2603 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2604 assertEquals(serviceType, "testServiceType");
2607 public void setServiceTypeTestNetwork() throws JsonProcessingException{
2608 String requestScope = ModelType.network.toString();
2609 Boolean aLaCarteFlag = null;
2610 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2611 RequestDetails requestDetails = new RequestDetails();
2612 RequestInfo requestInfo = new RequestInfo();
2613 ModelInfo modelInfo = new ModelInfo();
2614 modelInfo.setModelName("networkModelName");
2615 requestInfo.setSource("VID");
2616 requestDetails.setModelInfo(modelInfo);
2617 requestDetails.setRequestInfo(requestInfo);
2618 sir.setRequestDetails(requestDetails);
2620 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2621 assertEquals(serviceType, "networkModelName");