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.assertNotNull;
33 import static org.junit.Assert.assertThat;
34 import static org.junit.Assert.assertTrue;
35 import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
36 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
37 import static org.onap.so.logger.MdcConstants.CLIENT_ID;
38 import static org.onap.so.logger.MdcConstants.ENDTIME;
39 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
40 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
41 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
42 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
43 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
44 import static org.onap.so.logger.MdcConstants.STATUSCODE;
45 import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
49 import java.io.IOException;
50 import java.net.MalformedURLException;
52 import java.net.URISyntaxException;
54 import java.nio.file.Files;
55 import java.nio.file.Paths;
56 import java.util.List;
59 import javax.ws.rs.core.MediaType;
60 import javax.ws.rs.core.Response;
62 import org.apache.http.HttpStatus;
63 import org.junit.Before;
64 import org.junit.Test;
65 import org.onap.logging.ref.slf4j.ONAPLogConstants;
66 import org.onap.so.db.catalog.beans.Service;
67 import org.onap.so.db.catalog.beans.ServiceRecipe;
68 import org.onap.so.db.request.beans.InfraActiveRequests;
69 import org.onap.so.logger.HttpHeadersConstants;
70 import org.onap.so.serviceinstancebeans.CloudConfiguration;
71 import org.onap.so.serviceinstancebeans.RequestError;
72 import org.onap.so.serviceinstancebeans.RequestParameters;
73 import org.onap.so.serviceinstancebeans.RequestReferences;
74 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
75 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
76 import org.springframework.beans.factory.annotation.Autowired;
77 import org.springframework.beans.factory.annotation.Value;
78 import org.springframework.http.HttpEntity;
79 import org.springframework.http.HttpHeaders;
80 import org.springframework.http.HttpMethod;
81 import org.springframework.http.ResponseEntity;
82 import org.springframework.util.ResourceUtils;
83 import org.springframework.web.util.UriComponentsBuilder;
85 import com.fasterxml.jackson.annotation.JsonInclude.Include;
86 import com.fasterxml.jackson.core.JsonParseException;
87 import com.fasterxml.jackson.core.JsonProcessingException;
88 import com.fasterxml.jackson.databind.DeserializationFeature;
89 import com.fasterxml.jackson.databind.JsonMappingException;
90 import com.fasterxml.jackson.databind.ObjectMapper;
91 import com.github.tomakehurst.wiremock.http.Fault;
93 import ch.qos.logback.classic.spi.ILoggingEvent;
96 public class ServiceInstancesTest extends BaseTest{
98 private final ObjectMapper mapper = new ObjectMapper();
99 private ObjectMapper errorMapper = new ObjectMapper();
102 private ServiceInstances servInstances;
104 @Value("${wiremock.server.port}")
105 private String wiremockPort;
107 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
108 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
110 private URL selfLink;
111 private URL initialUrl;
112 private int initialPort;
113 private HttpHeaders headers;
116 public void beforeClass() {
117 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
118 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
119 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
121 headers = new HttpHeaders();
122 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
123 headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
124 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
125 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
126 headers.set(CLIENT_ID, "VID");
127 headers.set(REQUESTOR_ID, "xxxxxx");
128 try { // generate one-time port number to avoid RANDOM port number later.
129 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
130 initialPort = initialUrl.getPort();
131 } catch (MalformedURLException e) {
134 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
135 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
136 .withStatus(HttpStatus.SC_OK)));
139 public String inputStream(String JsonInput)throws IOException{
140 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
141 return new String(Files.readAllBytes(Paths.get(JsonInput)));
144 private URL createExpectedSelfLink(String version, String requestId) {
145 System.out.println("createdUrl: " + initialUrl.toString());
147 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
148 } catch (MalformedURLException e) {
154 private String getWiremockResponseForCatalogdb(String file) {
156 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
157 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
158 } catch (IOException e) {
165 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
167 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
168 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
170 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
171 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
174 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
176 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
178 return restTemplate.exchange(builder.toUriString(),
179 reqMethod, request, String.class);
182 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
183 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
187 public void createServiceInstanceVIDDefault() throws IOException{
188 TestAppender.events.clear();
190 ServiceRecipe serviceRecipe = new ServiceRecipe();
191 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
192 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
193 serviceRecipe.setAction(Action.createInstance.toString());
194 serviceRecipe.setId(1);
195 serviceRecipe.setRecipeTimeout(180);
196 Service defaultService = new Service();
197 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
200 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
201 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
202 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
204 stubFor(get(urlMatching(".*/service/search/.*"))
205 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
206 .withBody(mapper.writeValueAsString(defaultService))
207 .withStatus(HttpStatus.SC_OK)));
209 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
210 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
211 .withBody(mapper.writeValueAsString(serviceRecipe))
212 .withStatus(HttpStatus.SC_OK)));
215 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
216 RequestReferences requestReferences = new RequestReferences();
217 requestReferences.setInstanceId("1882939");
218 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
219 expectedResponse.setRequestReferences(requestReferences);
220 uri = servInstanceuri + "v5/serviceInstances";
221 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
224 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
225 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
226 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
230 for(ILoggingEvent logEvent : TestAppender.events)
231 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
232 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
234 Map<String,String> mdc = logEvent.getMDCPropertyMap();
235 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
236 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
237 assertNotNull(mdc.get(INVOCATION_ID));
238 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
239 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(SERVICE_NAME));
240 assertEquals("INPROGRESS",mdc.get(STATUSCODE));
241 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
242 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
243 Map<String,String> mdc = logEvent.getMDCPropertyMap();
244 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
245 assertNotNull(mdc.get(ENDTIME));
246 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
247 assertNotNull(mdc.get(INVOCATION_ID));
248 assertEquals("202",mdc.get(RESPONSECODE));
249 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
250 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(SERVICE_NAME));
251 assertEquals("COMPLETE",mdc.get(STATUSCODE));
252 assertNotNull(mdc.get(RESPONSEDESC));
253 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
254 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
255 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
259 public void createServiceInstanceServiceInstancesUri() throws IOException{
260 ServiceRecipe serviceRecipe = new ServiceRecipe();
261 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
262 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
263 serviceRecipe.setAction(Action.createInstance.toString());
264 serviceRecipe.setId(1);
265 serviceRecipe.setRecipeTimeout(180);
266 Service defaultService = new Service();
267 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
269 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
270 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
271 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
274 stubFor(get(urlMatching(".*/service/search/.*"))
275 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
276 .withBody(mapper.writeValueAsString(defaultService))
277 .withStatus(HttpStatus.SC_OK)));
279 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
280 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
281 .withBody(mapper.writeValueAsString(serviceRecipe))
282 .withStatus(HttpStatus.SC_OK)));
284 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
285 RequestReferences requestReferences = new RequestReferences();
286 requestReferences.setInstanceId("1882939");
287 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
288 expectedResponse.setRequestReferences(requestReferences);
289 uri = servInstanceUriPrev7 + "v5";
290 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
293 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
294 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
295 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
298 public void createServiceInstanceBpelStatusError() throws IOException{
299 ServiceRecipe serviceRecipe = new ServiceRecipe();
300 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
301 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
302 serviceRecipe.setAction(Action.createInstance.toString());
303 serviceRecipe.setId(1);
304 serviceRecipe.setRecipeTimeout(180);
305 Service defaultService = new Service();
306 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
309 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
310 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
311 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
314 stubFor(get(urlMatching(".*/service/search/.*"))
315 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
316 .withBody(mapper.writeValueAsString(defaultService))
317 .withStatus(HttpStatus.SC_OK)));
319 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
321 .withBody(mapper.writeValueAsString(serviceRecipe))
322 .withStatus(HttpStatus.SC_OK)));
324 uri = servInstanceuri + "v5/serviceInstances";
325 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
327 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
330 public void createServiceInstanceBadGateway() throws IOException{
331 ServiceRecipe serviceRecipe = new ServiceRecipe();
332 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
333 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
334 serviceRecipe.setAction(Action.createInstance.toString());
335 serviceRecipe.setId(1);
336 serviceRecipe.setRecipeTimeout(180);
337 Service defaultService = new Service();
338 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
340 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
341 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
343 stubFor(get(urlMatching(".*/service/search/.*"))
344 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
345 .withBody(mapper.writeValueAsString(defaultService))
346 .withStatus(HttpStatus.SC_OK)));
348 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
349 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
350 .withBody(mapper.writeValueAsString(serviceRecipe))
351 .withStatus(HttpStatus.SC_OK)));
353 uri = servInstanceuri + "v5/serviceInstances";
354 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
356 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
359 public void createServiceInstanceEmptyResponse() throws IOException{
360 ServiceRecipe serviceRecipe = new ServiceRecipe();
361 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
362 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
363 serviceRecipe.setAction(Action.createInstance.toString());
364 serviceRecipe.setId(1);
365 serviceRecipe.setRecipeTimeout(180);
366 Service defaultService = new Service();
367 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
369 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
370 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
372 stubFor(get(urlMatching(".*/service/search/.*"))
373 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
374 .withBody(mapper.writeValueAsString(defaultService))
375 .withStatus(HttpStatus.SC_OK)));
377 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
378 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
379 .withBody(mapper.writeValueAsString(serviceRecipe))
380 .withStatus(HttpStatus.SC_OK)));
382 uri = servInstanceuri + "v5/serviceInstances";
383 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
385 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
388 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
389 TestAppender.events.clear();
390 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
391 HttpHeaders requestIDheaders = new HttpHeaders();
392 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
393 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, requestIDheaders);
395 Service defaultService = new Service();
396 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
398 stubFor(get(urlMatching(".*/service/search/.*"))
399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
400 .withBody(mapper.writeValueAsString(defaultService))
401 .withStatus(HttpStatus.SC_OK)));
404 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
405 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
406 .withStatus(HttpStatus.SC_NOT_FOUND)));
408 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
411 public void activateServiceInstanceNoRecipe() throws IOException{
412 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
413 Service defaultService = new Service();
414 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
415 stubFor(get(urlMatching(".*/service/search/.*"))
416 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
417 .withBody(mapper.writeValueAsString(defaultService))
418 .withStatus(HttpStatus.SC_OK)));
420 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
421 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
422 .withStatus(HttpStatus.SC_NOT_FOUND)));
424 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
426 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
429 public void activateServiceInstance() throws IOException{
430 ServiceRecipe serviceRecipe = new ServiceRecipe();
431 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
432 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
433 serviceRecipe.setAction(Action.createInstance.toString());
434 serviceRecipe.setId(1);
435 serviceRecipe.setRecipeTimeout(180);
436 Service defaultService = new Service();
437 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
439 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
440 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
441 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
443 stubFor(get(urlMatching(".*/service/search/.*"))
444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
445 .withBody(mapper.writeValueAsString(defaultService))
446 .withStatus(HttpStatus.SC_OK)));
448 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
449 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
450 .withBody(mapper.writeValueAsString(serviceRecipe))
451 .withStatus(HttpStatus.SC_OK)));
453 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
454 RequestReferences requestReferences = new RequestReferences();
455 requestReferences.setInstanceId("1882939");
456 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
457 expectedResponse.setRequestReferences(requestReferences);
458 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
459 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
461 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
462 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
463 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
466 public void deactivateServiceInstance() throws IOException{
468 ServiceRecipe serviceRecipe = new ServiceRecipe();
469 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
470 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
471 serviceRecipe.setAction(Action.createInstance.toString());
472 serviceRecipe.setId(1);
473 serviceRecipe.setRecipeTimeout(180);
474 Service defaultService = new Service();
475 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
477 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
478 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
479 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
481 stubFor(get(urlMatching(".*/service/.*"))
482 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
483 .withBody(mapper.writeValueAsString(defaultService))
484 .withStatus(HttpStatus.SC_OK)));
486 stubFor(get(urlMatching(".*/service/search/.*"))
487 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
488 .withBody(mapper.writeValueAsString(defaultService))
489 .withStatus(HttpStatus.SC_OK)));
491 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
492 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
493 .withBody(mapper.writeValueAsString(serviceRecipe))
494 .withStatus(HttpStatus.SC_OK)));
497 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
498 RequestReferences requestReferences = new RequestReferences();
499 requestReferences.setInstanceId("1882939");
500 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
501 expectedResponse.setRequestReferences(requestReferences);
502 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
503 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
505 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
506 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
507 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
510 public void deleteServiceInstance() throws IOException {
511 ServiceRecipe serviceRecipe = new ServiceRecipe();
512 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
513 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
514 serviceRecipe.setAction(Action.createInstance.toString());
515 serviceRecipe.setId(1);
516 serviceRecipe.setRecipeTimeout(180);
517 Service defaultService = new Service();
518 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
520 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
522 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
524 stubFor(get(urlMatching(".*/service/.*"))
525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
526 .withBody(mapper.writeValueAsString(defaultService))
527 .withStatus(HttpStatus.SC_OK)));
529 stubFor(get(urlMatching(".*/service/search/.*"))
530 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
531 .withBody(mapper.writeValueAsString(defaultService))
532 .withStatus(HttpStatus.SC_OK)));
534 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
535 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
536 .withBody(mapper.writeValueAsString(serviceRecipe))
537 .withStatus(HttpStatus.SC_OK)));
539 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
540 RequestReferences requestReferences = new RequestReferences();
541 requestReferences.setInstanceId("1882939");
542 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
543 expectedResponse.setRequestReferences(requestReferences);
544 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
545 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
547 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
548 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
549 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
552 public void assignServiceInstance() throws IOException {
553 ServiceRecipe serviceRecipe = new ServiceRecipe();
554 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
555 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
556 serviceRecipe.setAction(Action.createInstance.toString());
557 serviceRecipe.setId(1);
558 serviceRecipe.setRecipeTimeout(180);
559 Service defaultService = new Service();
560 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
562 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
563 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
564 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
566 stubFor(get(urlMatching(".*/service/.*"))
567 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
568 .withBody(mapper.writeValueAsString(defaultService))
569 .withStatus(HttpStatus.SC_OK)));
571 stubFor(get(urlMatching(".*/service/search/.*"))
572 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
573 .withBody(mapper.writeValueAsString(defaultService))
574 .withStatus(HttpStatus.SC_OK)));
576 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
577 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
578 .withBody(mapper.writeValueAsString(serviceRecipe))
579 .withStatus(HttpStatus.SC_OK)));
581 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
582 RequestReferences requestReferences = new RequestReferences();
583 requestReferences.setInstanceId("1882939");
584 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
585 expectedResponse.setRequestReferences(requestReferences);
586 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
587 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
589 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
590 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
591 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
595 public void unassignServiceInstance() throws IOException {
596 ServiceRecipe serviceRecipe = new ServiceRecipe();
597 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
598 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
599 serviceRecipe.setAction(Action.createInstance.toString());
600 serviceRecipe.setId(1);
601 serviceRecipe.setRecipeTimeout(180);
602 Service defaultService = new Service();
603 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
605 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
606 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
607 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
609 stubFor(get(urlMatching(".*/service/.*"))
610 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
611 .withBody(mapper.writeValueAsString(defaultService))
612 .withStatus(HttpStatus.SC_OK)));
614 stubFor(get(urlMatching(".*/service/search/.*"))
615 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
616 .withBody(mapper.writeValueAsString(defaultService))
617 .withStatus(HttpStatus.SC_OK)));
619 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
620 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
621 .withBody(mapper.writeValueAsString(serviceRecipe))
622 .withStatus(HttpStatus.SC_OK)));
624 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
625 RequestReferences requestReferences = new RequestReferences();
626 requestReferences.setInstanceId("1882939");
627 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
628 expectedResponse.setRequestReferences(requestReferences);
629 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
630 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
632 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
633 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
634 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
637 public void createPortConfiguration() throws IOException {
638 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
639 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
640 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
642 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
643 RequestReferences requestReferences = new RequestReferences();
644 requestReferences.setInstanceId("1882939");
645 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
646 expectedResponse.setRequestReferences(requestReferences);
647 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
648 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
650 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
651 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
652 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
653 assertTrue(response.getBody().contains("1882939"));
656 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
657 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
658 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
660 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
663 public void deletePortConfiguration() throws IOException {
664 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
665 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
666 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
669 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
670 RequestReferences requestReferences = new RequestReferences();
671 requestReferences.setInstanceId("1882939");
672 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
673 expectedResponse.setRequestReferences(requestReferences);
674 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
675 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
677 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
678 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
679 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
682 public void enablePort() throws IOException {
683 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
684 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
685 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
687 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
688 RequestReferences requestReferences = new RequestReferences();
689 requestReferences.setInstanceId("1882939");
690 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
691 expectedResponse.setRequestReferences(requestReferences);
692 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
693 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
695 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
696 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
697 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
700 public void disablePort() throws IOException {
701 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
702 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
703 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
705 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
706 RequestReferences requestReferences = new RequestReferences();
707 requestReferences.setInstanceId("1882939");
708 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
709 expectedResponse.setRequestReferences(requestReferences);
710 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
711 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
713 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
714 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
715 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
718 public void activatePort() throws IOException {
719 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
720 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
721 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
723 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
724 RequestReferences requestReferences = new RequestReferences();
725 requestReferences.setInstanceId("1882939");
726 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
727 expectedResponse.setRequestReferences(requestReferences);
728 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
729 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
731 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
732 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
733 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
736 public void deactivatePort() throws IOException {
737 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
738 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
739 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
741 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
742 RequestReferences requestReferences = new RequestReferences();
743 requestReferences.setInstanceId("1882939");
744 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
745 expectedResponse.setRequestReferences(requestReferences);
746 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
747 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
749 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
750 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
751 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
754 public void addRelationships() throws IOException {
755 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
756 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
757 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
759 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
760 RequestReferences requestReferences = new RequestReferences();
761 requestReferences.setInstanceId("1882939");
762 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
763 expectedResponse.setRequestReferences(requestReferences);
764 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
765 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
767 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
768 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
769 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
772 public void removeRelationships() throws IOException {
773 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
774 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
775 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
777 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
778 RequestReferences requestReferences = new RequestReferences();
779 requestReferences.setInstanceId("1882939");
780 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
781 expectedResponse.setRequestReferences(requestReferences);
782 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
783 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
785 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
786 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
787 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
790 public void createVnfInstanceNoALaCarte() throws IOException {
791 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
793 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
796 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
797 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
798 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
799 .withStatus(org.apache.http.HttpStatus.SC_OK)));
801 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
802 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
803 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
804 .withStatus(org.apache.http.HttpStatus.SC_OK)));
806 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
807 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
808 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
809 .withStatus(org.apache.http.HttpStatus.SC_OK)));
812 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
813 RequestReferences requestReferences = new RequestReferences();
814 requestReferences.setInstanceId("1882939");
815 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
816 expectedResponse.setRequestReferences(requestReferences);
817 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
818 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
820 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
821 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
822 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
825 public void createVnfInstance() throws IOException {
826 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
827 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
828 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
830 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
831 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
832 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
833 .withStatus(org.apache.http.HttpStatus.SC_OK)));
834 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
835 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
836 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
837 .withStatus(org.apache.http.HttpStatus.SC_OK)));
840 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
841 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
842 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
843 .withStatus(org.apache.http.HttpStatus.SC_OK)));
845 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
846 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
847 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
848 .withStatus(org.apache.http.HttpStatus.SC_OK)));
851 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
852 RequestReferences requestReferences = new RequestReferences();
853 requestReferences.setInstanceId("1882939");
854 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
855 expectedResponse.setRequestReferences(requestReferences);
856 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
857 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
859 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
860 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
861 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
862 assertTrue(response.getBody().contains("1882939"));
865 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
866 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
867 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
869 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
872 public void createVnfInstanceInvalidVnfResource() throws IOException {
873 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
874 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
876 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
877 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
878 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
881 public void replaceVnfInstance() throws IOException {
882 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
883 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
884 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
886 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
887 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
888 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
889 .withStatus(org.apache.http.HttpStatus.SC_OK)));
891 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
892 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
893 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
894 .withStatus(org.apache.http.HttpStatus.SC_OK)));
896 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
897 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
898 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
899 .withStatus(org.apache.http.HttpStatus.SC_OK)));
901 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
902 RequestReferences requestReferences = new RequestReferences();
903 requestReferences.setInstanceId("1882939");
904 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
905 expectedResponse.setRequestReferences(requestReferences);
906 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
907 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
909 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
910 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
911 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
914 public void replaceVnfRecreateInstance() throws IOException {
915 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
916 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
917 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
919 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
920 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
921 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
922 .withStatus(org.apache.http.HttpStatus.SC_OK)));
924 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
925 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
926 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
927 .withStatus(org.apache.http.HttpStatus.SC_OK)));
929 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
930 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
931 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
932 .withStatus(org.apache.http.HttpStatus.SC_OK)));
935 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
936 RequestReferences requestReferences = new RequestReferences();
937 requestReferences.setInstanceId("1882939");
938 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
939 expectedResponse.setRequestReferences(requestReferences);
940 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
941 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
942 logger.debug(response.getBody());
944 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
945 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
946 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
949 public void recreateVnfInstance() throws IOException {
950 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
951 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
952 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
954 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
955 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
956 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
957 .withStatus(org.apache.http.HttpStatus.SC_OK)));
959 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
960 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
961 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
962 .withStatus(org.apache.http.HttpStatus.SC_OK)));
964 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
965 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
966 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
967 .withStatus(org.apache.http.HttpStatus.SC_OK)));
970 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
971 RequestReferences requestReferences = new RequestReferences();
972 requestReferences.setInstanceId("1882939");
973 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
974 expectedResponse.setRequestReferences(requestReferences);
975 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
976 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
977 logger.debug(response.getBody());
979 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
980 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
981 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
984 public void updateVnfInstance() throws IOException {
985 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
986 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
987 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
989 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
990 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
991 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
992 .withStatus(org.apache.http.HttpStatus.SC_OK)));
994 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
995 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
996 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
997 .withStatus(org.apache.http.HttpStatus.SC_OK)));
999 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1000 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1001 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1002 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1003 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1006 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1007 RequestReferences requestReferences = new RequestReferences();
1008 requestReferences.setInstanceId("1882939");
1009 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1010 expectedResponse.setRequestReferences(requestReferences);
1011 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1012 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1014 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1015 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1016 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1019 public void applyUpdatedConfig() throws IOException {
1020 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1021 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1022 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1025 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1026 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1027 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1028 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1029 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1032 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1033 RequestReferences requestReferences = new RequestReferences();
1034 requestReferences.setInstanceId("1882939");
1035 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1036 expectedResponse.setRequestReferences(requestReferences);
1037 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1038 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1040 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1041 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1042 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1045 public void deleteVnfInstanceV5() throws IOException {
1046 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1048 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1050 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1051 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1052 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1053 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1054 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1056 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1057 RequestReferences requestReferences = new RequestReferences();
1058 requestReferences.setInstanceId("1882939");
1059 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1060 expectedResponse.setRequestReferences(requestReferences);
1061 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1062 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1064 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1065 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1066 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1069 public void createVfModuleInstance() throws IOException {
1070 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1071 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1072 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1073 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1075 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1076 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1077 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1078 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1080 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1081 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1082 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1083 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1085 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1086 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1087 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1089 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1090 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1091 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1092 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1093 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1095 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1096 RequestReferences requestReferences = new RequestReferences();
1097 requestReferences.setInstanceId("1882939");
1098 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1099 expectedResponse.setRequestReferences(requestReferences);
1100 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1101 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1103 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1104 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1105 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1106 assertTrue(response.getBody().contains("1882939"));
1109 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1110 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1111 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1112 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1114 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1115 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1116 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1117 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1119 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1120 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1121 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1122 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1123 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1125 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1127 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1128 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1130 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1131 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1132 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1133 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1134 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1136 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1137 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1138 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1139 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1141 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1142 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1143 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1144 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1147 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1148 "[?]vnfComponentType=vfModule&action=createInstance"))
1149 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1150 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1151 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1154 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1155 RequestReferences requestReferences = new RequestReferences();
1156 requestReferences.setInstanceId("1882939");
1157 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1158 expectedResponse.setRequestReferences(requestReferences);
1159 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1160 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1161 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1162 ObjectMapper mapper = new ObjectMapper();
1163 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1164 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1167 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1168 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1169 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1170 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1172 stubFor(get(urlMatching(".*/vnfResource/.*"))
1173 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1174 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1175 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1177 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1178 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1179 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1180 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1182 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1183 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1184 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1185 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1187 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1188 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1189 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1190 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1192 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1193 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1194 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1195 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1197 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1198 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1199 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1200 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1202 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1203 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1204 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1205 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1206 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1209 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1210 RequestReferences requestReferences = new RequestReferences();
1211 requestReferences.setInstanceId("1882939");
1212 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1213 expectedResponse.setRequestReferences(requestReferences);
1214 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1215 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1218 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1219 ObjectMapper mapper = new ObjectMapper();
1220 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1221 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1224 public void createVfModuleInstanceNoRecipe() throws IOException {
1226 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1227 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1228 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1229 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1231 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1232 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1233 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1234 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1235 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1237 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1239 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1240 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1242 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1243 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1244 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1245 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1246 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1248 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1249 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1251 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1252 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1253 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1256 public void replaceVfModuleInstance() throws IOException {
1257 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1258 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1259 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1261 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1262 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1263 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1264 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1265 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1267 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1268 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1269 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1270 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1271 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1273 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1274 RequestReferences requestReferences = new RequestReferences();
1275 requestReferences.setInstanceId("1882939");
1276 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1277 expectedResponse.setRequestReferences(requestReferences);
1278 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1279 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1281 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1282 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1283 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1286 public void updateVfModuleInstance() throws IOException {
1287 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1288 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1289 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1291 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1292 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1293 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1294 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1296 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1297 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1298 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1299 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1301 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1302 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1303 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1304 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1306 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1307 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1308 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1309 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1310 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1313 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1314 RequestReferences requestReferences = new RequestReferences();
1315 requestReferences.setInstanceId("1882939");
1316 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1317 expectedResponse.setRequestReferences(requestReferences);
1318 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1319 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1320 logger.debug(response.getBody());
1322 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1323 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1324 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1327 public void createVfModuleNoModelType() throws IOException{
1328 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1329 expectedRecord.setRequestStatus("FAILED");
1330 expectedRecord.setAction("createInstance");
1331 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1332 expectedRecord.setProgress(100L);
1333 expectedRecord.setSource("VID");
1334 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1335 expectedRecord.setLastModifiedBy("APIH");
1336 expectedRecord.setVfModuleName("testVfModule2");
1337 expectedRecord.setVfModuleModelName("serviceModel");
1338 expectedRecord.setRequestScope("vfModule");
1339 expectedRecord.setRequestAction("createInstance");
1340 expectedRecord.setRequestorId("zz9999");
1341 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1342 //VnfType is not sent in this request, should be blank in db
1343 expectedRecord.setVnfType("");
1344 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1346 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1348 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1351 public void inPlaceSoftwareUpdate() throws IOException {
1352 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1353 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1354 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1356 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1357 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1358 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1359 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1360 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1363 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1364 RequestReferences requestReferences = new RequestReferences();
1365 requestReferences.setInstanceId("1882939");
1366 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1367 expectedResponse.setRequestReferences(requestReferences);
1368 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1369 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST, headers);
1371 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1372 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1373 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1377 public void deleteVfModuleInstance() throws IOException {
1378 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1379 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1380 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1382 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1383 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1384 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1385 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1386 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1388 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1389 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1390 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1391 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1392 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1395 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1396 RequestReferences requestReferences = new RequestReferences();
1397 requestReferences.setInstanceId("1882939");
1398 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1399 expectedResponse.setRequestReferences(requestReferences);
1400 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1401 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1403 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1404 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1405 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1408 public void deleteVfModuleNoModelInvariantId() throws IOException {
1409 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1410 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1411 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1413 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1414 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1415 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1416 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1417 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1420 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1421 RequestReferences requestReferences = new RequestReferences();
1422 requestReferences.setInstanceId("1882939");
1423 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1424 expectedResponse.setRequestReferences(requestReferences);
1425 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1426 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1428 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1429 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1430 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1433 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1434 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1435 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1436 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1438 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1439 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1440 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1441 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1442 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1444 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1445 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1446 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1447 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1448 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1451 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1452 RequestReferences requestReferences = new RequestReferences();
1453 requestReferences.setInstanceId("1882939");
1454 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1455 expectedResponse.setRequestReferences(requestReferences);
1456 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1457 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1459 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1460 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1461 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1464 public void createVolumeGroupInstance() throws IOException {
1465 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1466 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1467 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1469 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1470 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1471 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1472 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1474 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1476 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1477 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1479 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1480 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1481 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1482 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1483 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1486 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1487 RequestReferences requestReferences = new RequestReferences();
1488 requestReferences.setInstanceId("1882939");
1489 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1490 expectedResponse.setRequestReferences(requestReferences);
1491 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1492 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1494 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1495 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1496 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1497 assertTrue(response.getBody().contains("1882939"));
1500 public void updateVolumeGroupInstance() throws IOException {
1501 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1502 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1503 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1505 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1507 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1508 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1510 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1511 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1512 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1513 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1515 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1516 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1517 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1518 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1519 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1522 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1523 RequestReferences requestReferences = new RequestReferences();
1524 requestReferences.setInstanceId("1882939");
1525 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1526 expectedResponse.setRequestReferences(requestReferences);
1527 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1528 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1530 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1531 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1532 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1535 public void deleteVolumeGroupInstance() throws IOException {
1536 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1537 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1538 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
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(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1545 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1546 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1547 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1549 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1551 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1552 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1554 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1555 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1556 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1557 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1558 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1561 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1562 RequestReferences requestReferences = new RequestReferences();
1563 requestReferences.setInstanceId("1882939");
1564 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1565 expectedResponse.setRequestReferences(requestReferences);
1566 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1567 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1569 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1570 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1571 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1574 public void createNetworkInstance() throws IOException {
1575 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1576 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1577 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1579 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1580 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1581 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1582 .withStatus(HttpStatus.SC_OK)));
1584 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1585 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1586 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1587 .withStatus(HttpStatus.SC_OK)));
1589 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1590 "modelName=GR-API-DEFAULT&action=createInstance"))
1591 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1592 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1593 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1596 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1597 RequestReferences requestReferences = new RequestReferences();
1598 requestReferences.setInstanceId("1882939");
1599 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1600 expectedResponse.setRequestReferences(requestReferences);
1601 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1602 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1604 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1605 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1606 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1609 public void updateNetworkInstance() throws IOException {
1610 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1611 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1612 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1614 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1615 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1616 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1617 .withStatus(HttpStatus.SC_OK)));
1619 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1620 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1621 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1622 .withStatus(HttpStatus.SC_OK)));
1624 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1625 "modelName=GR-API-DEFAULT&action=updateInstance"))
1626 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1627 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1628 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1630 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1631 RequestReferences requestReferences = new RequestReferences();
1632 requestReferences.setInstanceId("1882939");
1633 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1634 expectedResponse.setRequestReferences(requestReferences);
1635 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1636 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1638 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1639 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1640 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1641 assertTrue(response.getBody().contains("1882939"));
1644 public void deleteNetworkInstance() throws IOException {
1645 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1646 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1647 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1649 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1650 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1651 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1652 .withStatus(HttpStatus.SC_OK)));
1654 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1656 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1657 .withStatus(HttpStatus.SC_OK)));
1659 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1660 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1661 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1662 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1663 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1666 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1667 RequestReferences requestReferences = new RequestReferences();
1668 requestReferences.setInstanceId("1882939");
1669 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1670 expectedResponse.setRequestReferences(requestReferences);
1671 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1672 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1674 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1675 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1676 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1679 public void deleteNetworkInstanceNoReqParams() throws IOException {
1680 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1681 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1682 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1684 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1685 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1686 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1687 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1688 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1692 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1693 RequestReferences requestReferences = new RequestReferences();
1694 requestReferences.setInstanceId("1882939");
1695 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1696 expectedResponse.setRequestReferences(requestReferences);
1697 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1698 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1700 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1701 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1702 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1705 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1707 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1708 expectedRecord.setRequestStatus("FAILED");
1709 expectedRecord.setStatusMessage("Error mapping request: ");
1710 expectedRecord.setProgress(100L);
1711 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1712 expectedRecord.setLastModifiedBy("APIH");
1713 expectedRecord.setRequestScope("network");
1714 expectedRecord.setRequestAction("deleteInstance");
1715 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1717 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1718 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1722 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1725 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1726 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1727 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1729 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1733 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1734 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1735 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1736 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1738 ServiceRecipe serviceRecipe = new ServiceRecipe();
1739 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1740 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1741 serviceRecipe.setAction(Action.createInstance.toString());
1742 serviceRecipe.setId(1);
1743 serviceRecipe.setRecipeTimeout(180);
1744 Service defaultService = new Service();
1745 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1747 stubFor(get(urlMatching(".*/service/.*"))
1748 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1749 .withBody(mapper.writeValueAsString(defaultService))
1750 .withStatus(HttpStatus.SC_OK)));
1752 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1753 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1754 .withBody(mapper.writeValueAsString(serviceRecipe))
1755 .withStatus(HttpStatus.SC_OK)));
1757 uri = servInstanceuri + "v7" + "/serviceInstances";
1758 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1761 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1762 RequestReferences requestReferences = new RequestReferences();
1763 requestReferences.setInstanceId("1882939");
1764 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1765 expectedResponse.setRequestReferences(requestReferences);
1767 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1768 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1769 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1773 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1774 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1775 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1776 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1778 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1779 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1780 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1781 .withStatus(HttpStatus.SC_OK)));
1783 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1784 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1785 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1786 .withStatus(HttpStatus.SC_OK)));
1788 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1789 "modelName=GR-API-DEFAULT&action=createInstance"))
1790 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1791 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1792 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1794 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1795 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1798 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1799 RequestReferences requestReferences = new RequestReferences();
1800 requestReferences.setInstanceId("1882939");
1801 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1802 expectedResponse.setRequestReferences(requestReferences);
1804 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1805 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1806 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1810 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1811 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1812 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1813 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1815 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1816 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1819 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1820 RequestReferences requestReferences = new RequestReferences();
1821 requestReferences.setInstanceId("1882939");
1822 expectedResponse.setRequestReferences(requestReferences);
1824 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1828 public void createNetworkInstanceTestApiGrApi() throws IOException {
1829 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1830 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1831 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1833 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1834 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1835 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1836 .withStatus(HttpStatus.SC_OK)));
1838 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1839 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1840 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1841 .withStatus(HttpStatus.SC_OK)));
1843 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1844 "modelName=GR-API-DEFAULT&action=createInstance"))
1845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1846 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1847 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1849 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1850 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
1853 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1854 RequestReferences requestReferences = new RequestReferences();
1855 requestReferences.setInstanceId("1882939");
1856 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1857 expectedResponse.setRequestReferences(requestReferences);
1859 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1860 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1861 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1865 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1866 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1867 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1868 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1870 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1871 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1872 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1873 .withStatus(HttpStatus.SC_OK)));
1875 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1876 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1877 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1878 .withStatus(HttpStatus.SC_OK)));
1880 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1881 "modelName=VNF-API-DEFAULT&action=createInstance"))
1882 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1883 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1884 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1886 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1887 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
1890 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1891 RequestReferences requestReferences = new RequestReferences();
1892 requestReferences.setInstanceId("1882939");
1893 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1894 expectedResponse.setRequestReferences(requestReferences);
1896 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1897 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1898 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1902 public void activateServiceInstanceRequestStatus() throws IOException{
1903 ServiceRecipe serviceRecipe = new ServiceRecipe();
1904 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1905 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1906 serviceRecipe.setAction(Action.createInstance.toString());
1907 serviceRecipe.setId(1);
1908 serviceRecipe.setRecipeTimeout(180);
1909 Service defaultService = new Service();
1910 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1912 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1913 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1914 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1916 stubFor(get(urlMatching(".*/service/.*"))
1917 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1918 .withBody(mapper.writeValueAsString(defaultService))
1919 .withStatus(HttpStatus.SC_OK)));
1921 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1922 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1923 .withBody(mapper.writeValueAsString(serviceRecipe))
1924 .withStatus(HttpStatus.SC_OK)));
1927 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1928 RequestReferences requestReferences = new RequestReferences();
1929 requestReferences.setInstanceId("1882939");
1930 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1931 expectedResponse.setRequestReferences(requestReferences);
1932 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
1933 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
1935 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1936 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1937 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1941 public void invalidRequestId() throws IOException {
1942 String illegalRequestId = "1234";
1943 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
1944 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
1945 uri = servInstanceuri + "v5/serviceInstances";
1946 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
1948 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1949 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
1952 public void invalidBPELResponse() throws IOException{
1954 ServiceRecipe serviceRecipe = new ServiceRecipe();
1955 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1956 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1957 serviceRecipe.setAction(Action.createInstance.toString());
1958 serviceRecipe.setId(1);
1959 serviceRecipe.setRecipeTimeout(180);
1960 Service defaultService = new Service();
1961 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1963 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1964 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1965 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1967 stubFor(get(urlMatching(".*/service/.*"))
1968 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1969 .withBody(mapper.writeValueAsString(defaultService))
1970 .withStatus(HttpStatus.SC_OK)));
1972 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1973 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1974 .withBody(mapper.writeValueAsString(serviceRecipe))
1975 .withStatus(HttpStatus.SC_OK)));
1977 uri = servInstanceuri + "v5/serviceInstances";
1978 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
1980 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1981 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1982 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
1985 public void unauthorizedBPELResponse() throws IOException{
1987 ServiceRecipe serviceRecipe = new ServiceRecipe();
1988 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1989 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1990 serviceRecipe.setAction(Action.createInstance.toString());
1991 serviceRecipe.setId(1);
1992 serviceRecipe.setRecipeTimeout(180);
1993 Service defaultService = new Service();
1994 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1996 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1997 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1998 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2000 stubFor(get(urlMatching(".*/service/.*"))
2001 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2002 .withBody(mapper.writeValueAsString(defaultService))
2003 .withStatus(HttpStatus.SC_OK)));
2005 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2006 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2007 .withBody(mapper.writeValueAsString(serviceRecipe))
2008 .withStatus(HttpStatus.SC_OK)));
2010 uri = servInstanceuri + "v5/serviceInstances";
2011 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2013 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2014 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2015 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2019 public void invalidBPELResponse2() throws IOException{
2021 ServiceRecipe serviceRecipe = new ServiceRecipe();
2022 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2023 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2024 serviceRecipe.setAction(Action.createInstance.toString());
2025 serviceRecipe.setId(1);
2026 serviceRecipe.setRecipeTimeout(180);
2027 Service defaultService = new Service();
2028 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2030 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2031 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2032 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2034 stubFor(get(urlMatching(".*/service/.*"))
2035 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2036 .withBody(mapper.writeValueAsString(defaultService))
2037 .withStatus(HttpStatus.SC_OK)));
2039 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2040 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2041 .withBody(mapper.writeValueAsString(serviceRecipe))
2042 .withStatus(HttpStatus.SC_OK)));
2043 uri = servInstanceuri + "v5/serviceInstances";
2044 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2046 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2047 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2048 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2052 public void createMacroServiceInstance() throws IOException{
2053 ServiceRecipe serviceRecipe = new ServiceRecipe();
2054 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2055 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2056 serviceRecipe.setAction(Action.createInstance.toString());
2057 serviceRecipe.setId(1);
2058 serviceRecipe.setRecipeTimeout(180);
2059 Service defaultService = new Service();
2060 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2062 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2063 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2064 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2066 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2067 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2068 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2070 stubFor(get(urlMatching(".*/service/.*"))
2071 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2072 .withBody(mapper.writeValueAsString(defaultService))
2073 .withStatus(HttpStatus.SC_OK)));
2075 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2076 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2077 .withBody(mapper.writeValueAsString(serviceRecipe))
2078 .withStatus(HttpStatus.SC_OK)));
2081 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2082 RequestReferences requestReferences = new RequestReferences();
2083 requestReferences.setInstanceId("1882939");
2084 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2085 expectedResponse.setRequestReferences(requestReferences);
2086 uri = servInstanceUriPrev7 + "v5";
2087 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2090 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2091 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2092 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2096 public void testUserParams() throws IOException {
2097 ObjectMapper mapper = new ObjectMapper();
2098 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2099 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2100 String userParamsTxt = inputStream("/userParams.txt");
2102 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2103 System.out.println(userParams);
2104 assertTrue(userParams.size() > 0);
2105 assertTrue(userParams.get(0).containsKey("name"));
2106 assertTrue(userParams.get(0).containsKey("value"));
2107 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2111 public void testConfigureCloudConfig() throws IOException {
2112 ObjectMapper mapper = new ObjectMapper();
2113 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2114 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2116 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2117 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2121 public void testMapToLegacyRequest() throws IOException {
2122 ObjectMapper mapper = new ObjectMapper();
2123 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2124 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2125 servInstances.mapToLegacyRequest(request.getRequestDetails());
2126 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2127 assertThat(request, sameBeanAs(expected));
2130 public void scaleOutVfModule() throws IOException {
2131 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2132 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2133 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2135 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2136 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2137 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2138 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2140 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2141 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2142 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2143 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2145 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2146 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2147 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2148 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2151 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2152 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2153 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2154 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2156 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2157 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2158 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2161 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2162 RequestReferences requestReferences = new RequestReferences();
2163 requestReferences.setInstanceId("1882939");
2164 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2165 expectedResponse.setRequestReferences(requestReferences);
2166 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2167 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2169 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2170 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2171 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2172 assertTrue(response.getBody().contains("1882939"));
2175 public void createServiceInstanceBadResponse() throws IOException{
2176 ServiceRecipe serviceRecipe = new ServiceRecipe();
2177 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2178 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2179 serviceRecipe.setAction(Action.createInstance.toString());
2180 serviceRecipe.setId(1);
2181 serviceRecipe.setRecipeTimeout(180);
2182 Service defaultService = new Service();
2183 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2185 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2186 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2187 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2189 stubFor(get(urlMatching(".*/service/.*"))
2190 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2191 .withBody(mapper.writeValueAsString(defaultService))
2192 .withStatus(HttpStatus.SC_OK)));
2194 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2195 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2196 .withBody(mapper.writeValueAsString(serviceRecipe))
2197 .withStatus(HttpStatus.SC_OK)));
2199 uri = servInstanceuri + "v5/serviceInstances";
2200 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2202 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2203 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2204 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2207 public void createServiceInstanceDuplicateError() throws IOException{
2208 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2209 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2210 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2212 uri = servInstanceuri + "v5/serviceInstances";
2213 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2215 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2216 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2217 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2220 public void createServiceInstanceDuplicateHistoryCheck() throws IOException{
2221 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2222 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2223 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2224 .withStatus(HttpStatus.SC_ACCEPTED)));
2225 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2226 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2227 .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2229 uri = servInstanceuri + "v5/serviceInstances";
2230 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2232 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2233 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2234 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());
2237 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException{
2238 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2239 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2240 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2241 .withStatus(HttpStatus.SC_ACCEPTED)));
2242 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2244 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2246 uri = servInstanceuri + "v5/serviceInstances";
2247 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2249 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2250 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2251 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());
2254 public void createServiceInstanceDuplicate() throws IOException{
2255 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2256 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2257 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2259 uri = servInstanceuri + "v5/serviceInstances";
2260 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2262 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2263 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2264 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2268 public void createServiceInstanceSaveError() throws IOException{
2269 ServiceRecipe serviceRecipe = new ServiceRecipe();
2270 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2271 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2272 serviceRecipe.setAction(Action.createInstance.toString());
2273 serviceRecipe.setId(1);
2274 serviceRecipe.setRecipeTimeout(180);
2275 Service defaultService = new Service();
2276 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2277 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2278 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2279 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2280 stubFor(get(urlMatching(".*/service/.*"))
2281 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2282 .withBody(mapper.writeValueAsString(defaultService))
2283 .withStatus(HttpStatus.SC_OK)));
2285 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2286 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2287 .withBody(mapper.writeValueAsString(serviceRecipe))
2288 .withStatus(HttpStatus.SC_OK)));
2290 uri = servInstanceuri + "v5/serviceInstances";
2291 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2293 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2294 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2295 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2298 public void createPortConfigurationSaveError() throws IOException {
2299 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2300 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2301 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2302 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2303 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2304 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2306 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2307 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2309 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2310 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2311 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2314 public void createPortConfigDbUpdateError() throws IOException {
2315 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2316 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2317 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2319 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2320 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2322 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2323 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2324 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2327 public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
2328 TestAppender.events.clear();
2329 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2330 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2331 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2333 stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2335 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2336 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2338 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
2339 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2340 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2341 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2343 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
2344 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2345 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2346 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2347 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2348 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2350 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2351 RequestReferences requestReferences = new RequestReferences();
2352 requestReferences.setInstanceId("1882939");
2353 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2354 expectedResponse.setRequestReferences(requestReferences);
2355 uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2356 ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2358 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2359 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2360 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2361 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2363 for(ILoggingEvent logEvent : TestAppender.events){
2364 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging") &&
2365 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")){
2366 Map<String,String> mdc = logEvent.getMDCPropertyMap();
2367 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2368 assertEquals("VID",mdc.get(PARTNERNAME));
2373 public void createInstanceGroup() throws IOException{
2374 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2375 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2376 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2379 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2380 RequestReferences requestReferences = new RequestReferences();
2381 requestReferences.setInstanceId("1882939");
2382 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2383 expectedResponse.setRequestReferences(requestReferences);
2384 uri = servInstanceuri + "/v7/instanceGroups";
2385 ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2388 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2389 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2390 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2393 public void deleteInstanceGroup() throws IOException{
2394 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2395 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2396 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2399 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2400 RequestReferences requestReferences = new RequestReferences();
2401 requestReferences.setInstanceId("1882939");
2402 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2403 expectedResponse.setRequestReferences(requestReferences);
2404 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2405 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2408 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2409 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2410 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2413 public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
2414 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2415 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2417 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2418 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2419 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2422 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
2423 HttpHeaders noPartnerHeaders = new HttpHeaders();
2424 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2425 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2426 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2427 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2429 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2430 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2431 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2434 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException{
2435 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2436 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2437 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2439 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2440 RequestReferences requestReferences = new RequestReferences();
2441 requestReferences.setInstanceId("1882939");
2442 expectedResponse.setRequestReferences(requestReferences);
2443 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2444 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2447 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2448 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2449 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2452 public void addMembers() throws IOException{
2453 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2454 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2455 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2457 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2458 RequestReferences requestReferences = new RequestReferences();
2459 requestReferences.setInstanceId("1882939");
2460 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2461 expectedResponse.setRequestReferences(requestReferences);
2462 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2463 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2466 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2467 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2468 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2471 public void removeMembers() throws IOException{
2472 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2473 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2474 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2476 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2477 RequestReferences requestReferences = new RequestReferences();
2478 requestReferences.setInstanceId("1882939");
2479 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2480 expectedResponse.setRequestReferences(requestReferences);
2481 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2482 ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2485 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2486 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2487 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2490 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2491 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2492 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2493 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2495 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2496 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2497 .withStatus(HttpStatus.SC_NOT_FOUND)));
2499 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
2500 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2501 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2502 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2503 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2506 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2507 RequestReferences requestReferences = new RequestReferences();
2508 requestReferences.setInstanceId("1882939");
2509 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2510 expectedResponse.setRequestReferences(requestReferences);
2511 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2512 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2514 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2515 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2516 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2519 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2520 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2522 .withStatus(HttpStatus.SC_NOT_FOUND)));
2524 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2525 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2527 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2528 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2529 assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");