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;
37 import java.io.IOException;
39 import java.nio.file.Files;
40 import java.nio.file.Paths;
41 import java.util.List;
44 import javax.ws.rs.core.MediaType;
45 import javax.ws.rs.core.Response;
47 import org.apache.http.HttpStatus;
48 import org.junit.Before;
49 import org.junit.Ignore;
50 import org.junit.Test;
51 import org.onap.logging.ref.slf4j.ONAPLogConstants;
52 import org.onap.so.db.catalog.beans.Service;
53 import org.onap.so.db.catalog.beans.ServiceRecipe;
54 import org.onap.so.db.request.beans.InfraActiveRequests;
55 import org.onap.so.logger.MsoLogger;
56 import org.onap.so.serviceinstancebeans.CloudConfiguration;
57 import org.onap.so.serviceinstancebeans.ModelInfo;
58 import org.onap.so.serviceinstancebeans.RequestError;
59 import org.onap.so.serviceinstancebeans.RequestParameters;
60 import org.onap.so.serviceinstancebeans.RequestReferences;
61 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
62 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
63 import org.springframework.beans.factory.annotation.Autowired;
64 import org.springframework.beans.factory.annotation.Value;
65 import org.springframework.http.HttpEntity;
66 import org.springframework.http.HttpHeaders;
67 import org.springframework.http.HttpMethod;
68 import org.springframework.http.ResponseEntity;
69 import org.springframework.util.ResourceUtils;
70 import org.springframework.web.util.UriComponentsBuilder;
72 import com.fasterxml.jackson.annotation.JsonInclude.Include;
73 import com.fasterxml.jackson.databind.DeserializationFeature;
74 import com.fasterxml.jackson.databind.ObjectMapper;
75 import com.github.tomakehurst.wiremock.http.Fault;
77 import ch.qos.logback.classic.spi.ILoggingEvent;
80 public class ServiceInstancesTest extends BaseTest{
82 private final ObjectMapper mapper = new ObjectMapper();
85 private ServiceInstances servInstances;
87 @Value("${wiremock.server.port}")
88 private String wiremockPort;
90 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
91 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
95 public void beforeClass() {
96 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
97 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
98 .withStatus(HttpStatus.SC_OK)));
101 public String inputStream(String JsonInput)throws IOException{
102 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
103 return new String(Files.readAllBytes(Paths.get(JsonInput)));
106 private String getWiremockResponseForCatalogdb(String file) {
108 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
109 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
110 } catch (IOException e) {
117 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
119 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
120 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
122 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
123 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
126 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
128 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
130 return restTemplate.exchange(builder.toUriString(),
131 reqMethod, request, String.class);
134 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
135 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
139 public void test_mapJSONtoMSOStyle() throws IOException{
140 ObjectMapper mapper = new ObjectMapper();
141 mapper.setSerializationInclusion(Include.NON_NULL);
142 String testRequest= inputStream("/ServiceInstanceDefault.json");
143 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
144 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
145 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
146 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
147 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
148 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
149 assertEquals("10",modelInfo.getModelUuid());
153 public void createServiceInstanceVIDDefault() throws IOException{
154 TestAppender.events.clear();
156 ServiceRecipe serviceRecipe = new ServiceRecipe();
157 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
158 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
159 serviceRecipe.setAction(Action.createInstance.toString());
160 serviceRecipe.setId(1);
161 serviceRecipe.setRecipeTimeout(180);
162 Service defaultService = new Service();
163 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
166 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
167 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
168 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
170 stubFor(get(urlMatching(".*/service/search/.*"))
171 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
172 .withBody(mapper.writeValueAsString(defaultService))
173 .withStatus(HttpStatus.SC_OK)));
175 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
176 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
177 .withBody(mapper.writeValueAsString(serviceRecipe))
178 .withStatus(HttpStatus.SC_OK)));
179 HttpHeaders headers = new HttpHeaders();
180 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
181 headers.set(MsoLogger.CLIENT_ID, "VID");
183 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
184 RequestReferences requestReferences = new RequestReferences();
185 requestReferences.setInstanceId("1882939");
186 expectedResponse.setRequestReferences(requestReferences);
187 uri = servInstanceuri + "v5/serviceInstances";
188 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
190 ObjectMapper mapper = new ObjectMapper();
191 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
194 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
195 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
196 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
200 for(ILoggingEvent logEvent : TestAppender.events)
201 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
202 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
204 Map<String,String> mdc = logEvent.getMDCPropertyMap();
205 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
206 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
207 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
208 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
209 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
210 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
211 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
212 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
213 Map<String,String> mdc = logEvent.getMDCPropertyMap();
214 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
215 assertNotNull(mdc.get(MsoLogger.ENDTIME));
216 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
217 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
218 assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
219 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
220 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
221 assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
222 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
223 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
224 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
225 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
229 public void createServiceInstanceServiceInstancesUri() throws IOException{
230 ServiceRecipe serviceRecipe = new ServiceRecipe();
231 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
232 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
233 serviceRecipe.setAction(Action.createInstance.toString());
234 serviceRecipe.setId(1);
235 serviceRecipe.setRecipeTimeout(180);
236 Service defaultService = new Service();
237 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
239 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
240 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
241 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
244 stubFor(get(urlMatching(".*/service/search/.*"))
245 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
246 .withBody(mapper.writeValueAsString(defaultService))
247 .withStatus(HttpStatus.SC_OK)));
249 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
250 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
251 .withBody(mapper.writeValueAsString(serviceRecipe))
252 .withStatus(HttpStatus.SC_OK)));
255 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
256 RequestReferences requestReferences = new RequestReferences();
257 requestReferences.setInstanceId("1882939");
258 expectedResponse.setRequestReferences(requestReferences);
259 uri = servInstanceUriPrev7 + "v5";
260 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
262 ObjectMapper mapper = new ObjectMapper();
263 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
266 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
267 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
268 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
271 public void createServiceInstanceBpelStatusError() throws IOException{
272 ServiceRecipe serviceRecipe = new ServiceRecipe();
273 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
274 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
275 serviceRecipe.setAction(Action.createInstance.toString());
276 serviceRecipe.setId(1);
277 serviceRecipe.setRecipeTimeout(180);
278 Service defaultService = new Service();
279 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
282 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
283 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
284 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
287 stubFor(get(urlMatching(".*/service/search/.*"))
288 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
289 .withBody(mapper.writeValueAsString(defaultService))
290 .withStatus(HttpStatus.SC_OK)));
292 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
293 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
294 .withBody(mapper.writeValueAsString(serviceRecipe))
295 .withStatus(HttpStatus.SC_OK)));
297 uri = servInstanceuri + "v5/serviceInstances";
298 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
300 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
303 public void createServiceInstanceBadGateway() throws IOException{
304 ServiceRecipe serviceRecipe = new ServiceRecipe();
305 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
306 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
307 serviceRecipe.setAction(Action.createInstance.toString());
308 serviceRecipe.setId(1);
309 serviceRecipe.setRecipeTimeout(180);
310 Service defaultService = new Service();
311 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
313 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
314 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
316 stubFor(get(urlMatching(".*/service/search/.*"))
317 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
318 .withBody(mapper.writeValueAsString(defaultService))
319 .withStatus(HttpStatus.SC_OK)));
321 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
322 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
323 .withBody(mapper.writeValueAsString(serviceRecipe))
324 .withStatus(HttpStatus.SC_OK)));
326 uri = servInstanceuri + "v5/serviceInstances";
327 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
329 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
332 public void createServiceInstanceEmptyResponse() throws IOException{
333 ServiceRecipe serviceRecipe = new ServiceRecipe();
334 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
335 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
336 serviceRecipe.setAction(Action.createInstance.toString());
337 serviceRecipe.setId(1);
338 serviceRecipe.setRecipeTimeout(180);
339 Service defaultService = new Service();
340 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
342 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
343 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
345 stubFor(get(urlMatching(".*/service/search/.*"))
346 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
347 .withBody(mapper.writeValueAsString(defaultService))
348 .withStatus(HttpStatus.SC_OK)));
350 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
351 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
352 .withBody(mapper.writeValueAsString(serviceRecipe))
353 .withStatus(HttpStatus.SC_OK)));
355 uri = servInstanceuri + "v5/serviceInstances";
356 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
358 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
361 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
362 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
363 HttpHeaders headers = new HttpHeaders();
364 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
365 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, headers);
367 Service defaultService = new Service();
368 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
370 stubFor(get(urlMatching(".*/service/search/.*"))
371 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
372 .withBody(mapper.writeValueAsString(defaultService))
373 .withStatus(HttpStatus.SC_OK)));
376 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
377 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
378 .withStatus(HttpStatus.SC_NOT_FOUND)));
380 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
383 public void activateServiceInstanceNoRecipe() throws IOException{
384 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
385 Service defaultService = new Service();
386 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
387 stubFor(get(urlMatching(".*/service/search/.*"))
388 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
389 .withBody(mapper.writeValueAsString(defaultService))
390 .withStatus(HttpStatus.SC_OK)));
392 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
393 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
394 .withStatus(HttpStatus.SC_NOT_FOUND)));
396 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
398 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
401 public void activateServiceInstance() throws IOException{
402 ServiceRecipe serviceRecipe = new ServiceRecipe();
403 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
404 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
405 serviceRecipe.setAction(Action.createInstance.toString());
406 serviceRecipe.setId(1);
407 serviceRecipe.setRecipeTimeout(180);
408 Service defaultService = new Service();
409 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
411 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
412 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
413 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
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 .withBody(mapper.writeValueAsString(serviceRecipe))
423 .withStatus(HttpStatus.SC_OK)));
424 HttpHeaders headers = new HttpHeaders();
425 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
427 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
428 RequestReferences requestReferences = new RequestReferences();
429 requestReferences.setInstanceId("1882939");
430 expectedResponse.setRequestReferences(requestReferences);
431 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
432 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
434 ObjectMapper mapper = new ObjectMapper();
435 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
437 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
438 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
439 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
442 public void deactivateServiceInstance() throws IOException{
444 ServiceRecipe serviceRecipe = new ServiceRecipe();
445 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
446 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
447 serviceRecipe.setAction(Action.createInstance.toString());
448 serviceRecipe.setId(1);
449 serviceRecipe.setRecipeTimeout(180);
450 Service defaultService = new Service();
451 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
453 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
454 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
455 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
457 stubFor(get(urlMatching(".*/service/.*"))
458 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
459 .withBody(mapper.writeValueAsString(defaultService))
460 .withStatus(HttpStatus.SC_OK)));
462 stubFor(get(urlMatching(".*/service/search/.*"))
463 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
464 .withBody(mapper.writeValueAsString(defaultService))
465 .withStatus(HttpStatus.SC_OK)));
467 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
468 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
469 .withBody(mapper.writeValueAsString(serviceRecipe))
470 .withStatus(HttpStatus.SC_OK)));
473 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
474 RequestReferences requestReferences = new RequestReferences();
475 requestReferences.setInstanceId("1882939");
476 expectedResponse.setRequestReferences(requestReferences);
477 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
478 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
480 ObjectMapper mapper = new ObjectMapper();
481 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
483 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
484 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
485 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
488 public void deleteServiceInstance() throws IOException {
489 ServiceRecipe serviceRecipe = new ServiceRecipe();
490 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
491 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
492 serviceRecipe.setAction(Action.createInstance.toString());
493 serviceRecipe.setId(1);
494 serviceRecipe.setRecipeTimeout(180);
495 Service defaultService = new Service();
496 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
498 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
499 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
500 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
502 stubFor(get(urlMatching(".*/service/.*"))
503 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
504 .withBody(mapper.writeValueAsString(defaultService))
505 .withStatus(HttpStatus.SC_OK)));
507 stubFor(get(urlMatching(".*/service/search/.*"))
508 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
509 .withBody(mapper.writeValueAsString(defaultService))
510 .withStatus(HttpStatus.SC_OK)));
512 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
513 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
514 .withBody(mapper.writeValueAsString(serviceRecipe))
515 .withStatus(HttpStatus.SC_OK)));
517 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
518 RequestReferences requestReferences = new RequestReferences();
519 requestReferences.setInstanceId("1882939");
520 expectedResponse.setRequestReferences(requestReferences);
521 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
522 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
524 ObjectMapper mapper = new ObjectMapper();
525 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
527 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
528 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
529 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
532 public void assignServiceInstance() throws IOException {
533 ServiceRecipe serviceRecipe = new ServiceRecipe();
534 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
535 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
536 serviceRecipe.setAction(Action.createInstance.toString());
537 serviceRecipe.setId(1);
538 serviceRecipe.setRecipeTimeout(180);
539 Service defaultService = new Service();
540 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
542 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
543 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
544 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
546 stubFor(get(urlMatching(".*/service/.*"))
547 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
548 .withBody(mapper.writeValueAsString(defaultService))
549 .withStatus(HttpStatus.SC_OK)));
551 stubFor(get(urlMatching(".*/service/search/.*"))
552 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
553 .withBody(mapper.writeValueAsString(defaultService))
554 .withStatus(HttpStatus.SC_OK)));
556 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
557 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
558 .withBody(mapper.writeValueAsString(serviceRecipe))
559 .withStatus(HttpStatus.SC_OK)));
561 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
562 RequestReferences requestReferences = new RequestReferences();
563 requestReferences.setInstanceId("1882939");
564 expectedResponse.setRequestReferences(requestReferences);
565 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
566 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
568 ObjectMapper mapper = new ObjectMapper();
569 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
571 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
572 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
573 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
577 public void unassignServiceInstance() throws IOException {
578 ServiceRecipe serviceRecipe = new ServiceRecipe();
579 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
580 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
581 serviceRecipe.setAction(Action.createInstance.toString());
582 serviceRecipe.setId(1);
583 serviceRecipe.setRecipeTimeout(180);
584 Service defaultService = new Service();
585 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
587 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
588 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
589 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
591 stubFor(get(urlMatching(".*/service/.*"))
592 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
593 .withBody(mapper.writeValueAsString(defaultService))
594 .withStatus(HttpStatus.SC_OK)));
596 stubFor(get(urlMatching(".*/service/search/.*"))
597 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
598 .withBody(mapper.writeValueAsString(defaultService))
599 .withStatus(HttpStatus.SC_OK)));
601 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
602 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
603 .withBody(mapper.writeValueAsString(serviceRecipe))
604 .withStatus(HttpStatus.SC_OK)));
606 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
607 RequestReferences requestReferences = new RequestReferences();
608 requestReferences.setInstanceId("1882939");
609 expectedResponse.setRequestReferences(requestReferences);
610 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
611 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
613 ObjectMapper mapper = new ObjectMapper();
614 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
616 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
617 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
618 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
621 public void createPortConfiguration() throws IOException {
622 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
623 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
624 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
625 HttpHeaders headers = new HttpHeaders();
626 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
628 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
629 RequestReferences requestReferences = new RequestReferences();
630 requestReferences.setInstanceId("1882939");
631 expectedResponse.setRequestReferences(requestReferences);
632 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
633 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
635 ObjectMapper mapper = new ObjectMapper();
636 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
638 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
639 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
640 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
641 assertTrue(response.getBody().contains("1882939"));
644 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
645 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
646 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
648 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
651 public void deletePortConfiguration() throws IOException {
652 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
653 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
654 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
656 HttpHeaders headers = new HttpHeaders();
657 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
659 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
660 RequestReferences requestReferences = new RequestReferences();
661 requestReferences.setInstanceId("1882939");
662 expectedResponse.setRequestReferences(requestReferences);
663 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
664 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
666 ObjectMapper mapper = new ObjectMapper();
667 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
669 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
670 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
671 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
674 public void enablePort() throws IOException {
675 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
676 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
677 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
679 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
680 RequestReferences requestReferences = new RequestReferences();
681 requestReferences.setInstanceId("1882939");
682 expectedResponse.setRequestReferences(requestReferences);
683 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
684 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
686 ObjectMapper mapper = new ObjectMapper();
687 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
689 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
690 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
691 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
694 public void disablePort() throws IOException {
695 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
696 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
697 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
699 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
700 RequestReferences requestReferences = new RequestReferences();
701 requestReferences.setInstanceId("1882939");
702 expectedResponse.setRequestReferences(requestReferences);
703 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
704 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
706 ObjectMapper mapper = new ObjectMapper();
707 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
709 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
710 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
711 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
714 public void activatePort() throws IOException {
715 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
717 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
719 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
720 RequestReferences requestReferences = new RequestReferences();
721 requestReferences.setInstanceId("1882939");
722 expectedResponse.setRequestReferences(requestReferences);
723 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
724 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
726 ObjectMapper mapper = new ObjectMapper();
727 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
729 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
730 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
731 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
734 public void deactivatePort() throws IOException {
735 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
736 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
737 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
739 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
740 RequestReferences requestReferences = new RequestReferences();
741 requestReferences.setInstanceId("1882939");
742 expectedResponse.setRequestReferences(requestReferences);
743 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
744 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
746 ObjectMapper mapper = new ObjectMapper();
747 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
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)));
760 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
761 RequestReferences requestReferences = new RequestReferences();
762 requestReferences.setInstanceId("1882939");
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);
767 ObjectMapper mapper = new ObjectMapper();
768 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
770 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
771 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
772 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
775 public void removeRelationships() throws IOException {
776 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
777 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
778 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
781 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
782 RequestReferences requestReferences = new RequestReferences();
783 requestReferences.setInstanceId("1882939");
784 expectedResponse.setRequestReferences(requestReferences);
785 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
786 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
788 ObjectMapper mapper = new ObjectMapper();
789 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
791 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
792 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
793 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
796 public void createVnfInstanceNoALaCarte() throws IOException {
797 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
798 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
799 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
802 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
803 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
804 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
805 .withStatus(org.apache.http.HttpStatus.SC_OK)));
807 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
808 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
809 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
810 .withStatus(org.apache.http.HttpStatus.SC_OK)));
812 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
813 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
814 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
815 .withStatus(org.apache.http.HttpStatus.SC_OK)));
818 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
819 RequestReferences requestReferences = new RequestReferences();
820 requestReferences.setInstanceId("1882939");
821 expectedResponse.setRequestReferences(requestReferences);
822 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
823 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
825 ObjectMapper mapper = new ObjectMapper();
826 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
828 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
829 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
830 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
833 public void createVnfInstance() throws IOException {
834 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
835 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
836 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
838 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
839 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
840 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
841 .withStatus(org.apache.http.HttpStatus.SC_OK)));
842 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
843 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
844 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
845 .withStatus(org.apache.http.HttpStatus.SC_OK)));
848 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
849 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
850 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
851 .withStatus(org.apache.http.HttpStatus.SC_OK)));
853 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
854 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
855 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
856 .withStatus(org.apache.http.HttpStatus.SC_OK)));
858 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
859 HttpHeaders headers = new HttpHeaders();
860 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
862 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
863 RequestReferences requestReferences = new RequestReferences();
864 requestReferences.setInstanceId("1882939");
865 expectedResponse.setRequestReferences(requestReferences);
866 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
867 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
869 ObjectMapper mapper = new ObjectMapper();
870 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
872 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
873 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
874 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
875 assertTrue(response.getBody().contains("1882939"));
878 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
879 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
880 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
882 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
885 public void createVnfInstanceInvalidVnfResource() throws IOException {
886 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
887 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
889 ObjectMapper mapper = new ObjectMapper();
890 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
891 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
893 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
894 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
895 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
898 public void replaceVnfInstance() throws IOException {
899 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
900 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
901 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
903 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
904 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
905 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
906 .withStatus(org.apache.http.HttpStatus.SC_OK)));
908 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
909 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
910 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
911 .withStatus(org.apache.http.HttpStatus.SC_OK)));
913 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
914 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
915 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
916 .withStatus(org.apache.http.HttpStatus.SC_OK)));
918 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
919 RequestReferences requestReferences = new RequestReferences();
920 requestReferences.setInstanceId("1882939");
921 expectedResponse.setRequestReferences(requestReferences);
922 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
923 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
925 ObjectMapper mapper = new ObjectMapper();
926 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
928 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
929 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
930 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
933 public void replaceVnfRecreateInstance() throws IOException {
934 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
935 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
936 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
938 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
939 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
940 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
941 .withStatus(org.apache.http.HttpStatus.SC_OK)));
943 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
944 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
945 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
946 .withStatus(org.apache.http.HttpStatus.SC_OK)));
948 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
949 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
950 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
951 .withStatus(org.apache.http.HttpStatus.SC_OK)));
954 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
955 RequestReferences requestReferences = new RequestReferences();
956 requestReferences.setInstanceId("1882939");
957 expectedResponse.setRequestReferences(requestReferences);
958 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
959 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
960 logger.debug(response.getBody());
961 ObjectMapper mapper = new ObjectMapper();
962 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
964 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
965 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
966 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
969 public void recreateVnfInstance() throws IOException {
970 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
971 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
972 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
974 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
975 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
976 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
977 .withStatus(org.apache.http.HttpStatus.SC_OK)));
979 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
980 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
981 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
982 .withStatus(org.apache.http.HttpStatus.SC_OK)));
984 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
985 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
986 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
987 .withStatus(org.apache.http.HttpStatus.SC_OK)));
990 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
991 RequestReferences requestReferences = new RequestReferences();
992 requestReferences.setInstanceId("1882939");
993 expectedResponse.setRequestReferences(requestReferences);
994 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
995 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST);
996 logger.debug(response.getBody());
997 ObjectMapper mapper = new ObjectMapper();
998 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1000 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1001 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1002 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1005 public void updateVnfInstance() throws IOException {
1006 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1007 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1008 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1010 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
1011 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1012 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1013 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1015 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
1016 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1017 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1018 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1020 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1021 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1022 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1023 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1024 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1027 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1028 RequestReferences requestReferences = new RequestReferences();
1029 requestReferences.setInstanceId("1882939");
1030 expectedResponse.setRequestReferences(requestReferences);
1031 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1032 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
1034 ObjectMapper mapper = new ObjectMapper();
1035 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1037 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1038 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1039 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1042 public void applyUpdatedConfig() throws IOException {
1043 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1044 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1045 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1048 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1049 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1050 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1051 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1052 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1054 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
1055 HttpHeaders headers = new HttpHeaders();
1056 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1058 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1059 RequestReferences requestReferences = new RequestReferences();
1060 requestReferences.setInstanceId("1882939");
1061 expectedResponse.setRequestReferences(requestReferences);
1062 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1063 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1065 ObjectMapper mapper = new ObjectMapper();
1066 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1068 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1069 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1070 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1073 public void deleteVnfInstanceV5() throws IOException {
1074 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1076 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1078 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1079 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1081 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1082 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1084 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1085 RequestReferences requestReferences = new RequestReferences();
1086 requestReferences.setInstanceId("1882939");
1087 expectedResponse.setRequestReferences(requestReferences);
1088 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1089 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
1091 ObjectMapper mapper = new ObjectMapper();
1092 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1094 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1095 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1096 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1099 public void createVfModuleInstance() throws IOException {
1101 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1102 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1103 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1104 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1106 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1107 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1108 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1109 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1111 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1112 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1113 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1114 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1116 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1117 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1118 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1120 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1121 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1122 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1123 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1124 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1126 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1127 RequestReferences requestReferences = new RequestReferences();
1128 requestReferences.setInstanceId("1882939");
1129 expectedResponse.setRequestReferences(requestReferences);
1130 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1131 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
1133 ObjectMapper mapper = new ObjectMapper();
1134 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1136 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1137 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1138 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1139 assertTrue(response.getBody().contains("1882939"));
1142 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1143 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1144 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1145 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1147 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1148 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1149 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1150 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1152 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1153 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1154 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1155 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1156 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1158 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1159 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1160 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1161 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1163 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1164 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1165 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1166 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1167 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1169 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1170 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1171 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1172 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1174 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1175 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1176 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1177 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1180 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1181 "[?]vnfComponentType=vfModule&action=createInstance"))
1182 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1183 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1184 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1187 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1188 RequestReferences requestReferences = new RequestReferences();
1189 requestReferences.setInstanceId("1882939");
1190 expectedResponse.setRequestReferences(requestReferences);
1191 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1192 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
1193 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1194 ObjectMapper mapper = new ObjectMapper();
1195 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1196 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1199 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1200 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1201 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1202 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1204 stubFor(get(urlMatching(".*/vnfResource/.*"))
1205 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1206 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1207 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1209 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1210 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1211 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1212 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1214 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1215 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1216 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1217 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1219 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1220 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1221 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1222 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1224 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1225 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1226 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1227 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1229 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1230 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1231 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1232 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1234 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1235 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1236 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1237 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1238 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1241 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1242 RequestReferences requestReferences = new RequestReferences();
1243 requestReferences.setInstanceId("1882939");
1244 expectedResponse.setRequestReferences(requestReferences);
1245 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1246 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
1248 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1249 ObjectMapper mapper = new ObjectMapper();
1250 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1251 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1254 public void createVfModuleInstanceNoRecipe() throws IOException {
1256 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1257 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1258 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1259 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1261 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1262 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1263 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1264 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1265 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1267 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1268 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1269 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1270 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1272 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1273 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1274 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1275 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1276 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1278 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1279 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
1281 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1282 ObjectMapper mapper = new ObjectMapper();
1283 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1284 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1285 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1288 public void replaceVfModuleInstance() throws IOException {
1289 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1290 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1291 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1293 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1294 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1295 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1296 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1297 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1299 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1300 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1301 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1302 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1303 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1305 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1306 RequestReferences requestReferences = new RequestReferences();
1307 requestReferences.setInstanceId("1882939");
1308 expectedResponse.setRequestReferences(requestReferences);
1309 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1310 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
1312 ObjectMapper mapper = new ObjectMapper();
1313 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1315 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1316 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1317 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1320 public void updateVfModuleInstance() throws IOException {
1321 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1322 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1323 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1325 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1326 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1327 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1328 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1330 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1331 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1332 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1333 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1335 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1336 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1337 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1338 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1340 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1341 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1342 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1343 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1344 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1347 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1348 RequestReferences requestReferences = new RequestReferences();
1349 requestReferences.setInstanceId("1882939");
1350 expectedResponse.setRequestReferences(requestReferences);
1351 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1352 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
1353 logger.debug(response.getBody());
1355 ObjectMapper mapper = new ObjectMapper();
1356 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1358 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1359 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1360 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1363 public void createVfModuleNoModelType() throws IOException{
1364 HttpHeaders headers = new HttpHeaders();
1365 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1366 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1367 expectedRecord.setRequestStatus("FAILED");
1368 expectedRecord.setAction("createInstance");
1369 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1370 expectedRecord.setProgress(100L);
1371 expectedRecord.setSource("VID");
1372 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1373 expectedRecord.setLastModifiedBy("APIH");
1374 expectedRecord.setVfModuleName("testVfModule2");
1375 expectedRecord.setVfModuleModelName("serviceModel");
1376 expectedRecord.setRequestScope("vfModule");
1377 expectedRecord.setRequestAction("createInstance");
1378 expectedRecord.setRequestorId("zz9999");
1379 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1380 //VnfType is not sent in this request, should be blank in db
1381 expectedRecord.setVnfType("");
1382 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1384 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1386 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1389 public void inPlaceSoftwareUpdate() throws IOException {
1390 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1391 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1392 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1394 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1395 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1396 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1397 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1398 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1401 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1402 RequestReferences requestReferences = new RequestReferences();
1403 requestReferences.setInstanceId("1882939");
1404 expectedResponse.setRequestReferences(requestReferences);
1405 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1406 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
1408 ObjectMapper mapper = new ObjectMapper();
1409 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1411 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1412 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1413 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1417 public void deleteVfModuleInstance() throws IOException {
1418 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1419 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1420 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1422 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1423 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1424 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1425 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1426 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1428 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1429 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1430 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1431 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1432 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1435 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1436 RequestReferences requestReferences = new RequestReferences();
1437 requestReferences.setInstanceId("1882939");
1438 expectedResponse.setRequestReferences(requestReferences);
1439 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1440 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
1442 ObjectMapper mapper = new ObjectMapper();
1443 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1445 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1446 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1447 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1450 public void deleteVfModuleNoModelInvariantId() throws IOException {
1451 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1452 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1453 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1455 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1456 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1457 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1458 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1459 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1462 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1463 RequestReferences requestReferences = new RequestReferences();
1464 requestReferences.setInstanceId("1882939");
1465 expectedResponse.setRequestReferences(requestReferences);
1466 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1467 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE);
1469 ObjectMapper mapper = new ObjectMapper();
1470 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1472 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1473 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1474 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1477 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1478 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1479 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1480 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1482 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1483 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1484 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1485 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1486 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1488 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1489 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1490 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1491 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1492 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1495 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1496 RequestReferences requestReferences = new RequestReferences();
1497 requestReferences.setInstanceId("1882939");
1498 expectedResponse.setRequestReferences(requestReferences);
1499 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1500 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
1502 ObjectMapper mapper = new ObjectMapper();
1503 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1505 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1506 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1507 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1510 public void createVolumeGroupInstance() throws IOException {
1511 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1512 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1513 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1515 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1516 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1517 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1518 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1520 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1522 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1523 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1525 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1526 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1527 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1528 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1529 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1532 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1533 RequestReferences requestReferences = new RequestReferences();
1534 requestReferences.setInstanceId("1882939");
1535 expectedResponse.setRequestReferences(requestReferences);
1536 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1537 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
1539 ObjectMapper mapper = new ObjectMapper();
1540 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1542 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1543 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1544 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1545 assertTrue(response.getBody().contains("1882939"));
1548 public void updateVolumeGroupInstance() throws IOException {
1549 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1551 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1553 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1554 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1555 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1556 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1558 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1559 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1560 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1561 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1563 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1564 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1565 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1566 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1567 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1570 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1571 RequestReferences requestReferences = new RequestReferences();
1572 requestReferences.setInstanceId("1882939");
1573 expectedResponse.setRequestReferences(requestReferences);
1574 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1575 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
1577 ObjectMapper mapper = new ObjectMapper();
1578 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1580 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1581 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1582 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1585 public void deleteVolumeGroupInstance() throws IOException {
1586 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1587 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1588 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1590 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1591 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1592 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1594 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1596 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1597 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1599 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1601 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1602 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1604 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1605 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1606 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1607 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1608 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1611 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1612 RequestReferences requestReferences = new RequestReferences();
1613 requestReferences.setInstanceId("1882939");
1614 expectedResponse.setRequestReferences(requestReferences);
1615 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1616 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
1618 ObjectMapper mapper = new ObjectMapper();
1619 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1621 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1622 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1623 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1626 public void createNetworkInstance() throws IOException {
1627 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1628 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1629 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1631 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1632 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1633 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1634 .withStatus(HttpStatus.SC_OK)));
1636 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1637 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1638 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1639 .withStatus(HttpStatus.SC_OK)));
1641 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1642 "modelName=GR-API-DEFAULT&action=createInstance"))
1643 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1644 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1645 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1647 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
1648 HttpHeaders headers = new HttpHeaders();
1649 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1651 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1652 RequestReferences requestReferences = new RequestReferences();
1653 requestReferences.setInstanceId("1882939");
1654 expectedResponse.setRequestReferences(requestReferences);
1655 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1656 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1658 ObjectMapper mapper = new ObjectMapper();
1659 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1661 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1662 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1663 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1666 public void updateNetworkInstance() throws IOException {
1667 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1668 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1669 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1671 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1672 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1673 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1674 .withStatus(HttpStatus.SC_OK)));
1676 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1677 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1678 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1679 .withStatus(HttpStatus.SC_OK)));
1681 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1682 "modelName=GR-API-DEFAULT&action=updateInstance"))
1683 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1684 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1685 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1687 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1688 RequestReferences requestReferences = new RequestReferences();
1689 requestReferences.setInstanceId("1882939");
1690 expectedResponse.setRequestReferences(requestReferences);
1691 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1692 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
1694 ObjectMapper mapper = new ObjectMapper();
1695 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1697 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1698 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1699 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1700 assertTrue(response.getBody().contains("1882939"));
1703 public void deleteNetworkInstance() throws IOException {
1704 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1705 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1706 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1708 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1709 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1710 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1711 .withStatus(HttpStatus.SC_OK)));
1713 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1714 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1715 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1716 .withStatus(HttpStatus.SC_OK)));
1718 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1719 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1720 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1721 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1722 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1725 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1726 RequestReferences requestReferences = new RequestReferences();
1727 requestReferences.setInstanceId("1882939");
1728 expectedResponse.setRequestReferences(requestReferences);
1729 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1730 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
1732 ObjectMapper mapper = new ObjectMapper();
1733 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1735 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1736 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1737 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1740 public void deleteNetworkInstanceNoReqParams() throws IOException {
1741 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1742 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1743 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1745 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1746 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1747 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1748 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1749 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1753 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1754 RequestReferences requestReferences = new RequestReferences();
1755 requestReferences.setInstanceId("1882939");
1756 expectedResponse.setRequestReferences(requestReferences);
1757 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1758 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
1760 ObjectMapper mapper = new ObjectMapper();
1761 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1763 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1764 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1765 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1768 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1769 HttpHeaders headers = new HttpHeaders();
1770 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1772 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1773 expectedRecord.setRequestStatus("FAILED");
1774 expectedRecord.setStatusMessage("Error mapping request: ");
1775 expectedRecord.setProgress(100L);
1776 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1777 expectedRecord.setLastModifiedBy("APIH");
1778 expectedRecord.setRequestScope("network");
1779 expectedRecord.setRequestAction("deleteInstance");
1780 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1782 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1783 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1787 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1790 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1791 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1792 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1794 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1798 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1799 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1800 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1801 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1803 ServiceRecipe serviceRecipe = new ServiceRecipe();
1804 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1805 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1806 serviceRecipe.setAction(Action.createInstance.toString());
1807 serviceRecipe.setId(1);
1808 serviceRecipe.setRecipeTimeout(180);
1809 Service defaultService = new Service();
1810 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1812 stubFor(get(urlMatching(".*/service/.*"))
1813 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1814 .withBody(mapper.writeValueAsString(defaultService))
1815 .withStatus(HttpStatus.SC_OK)));
1817 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1818 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1819 .withBody(mapper.writeValueAsString(serviceRecipe))
1820 .withStatus(HttpStatus.SC_OK)));
1822 uri = servInstanceuri + "v7" + "/serviceInstances";
1823 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
1826 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1827 RequestReferences requestReferences = new RequestReferences();
1828 requestReferences.setInstanceId("1882939");
1829 expectedResponse.setRequestReferences(requestReferences);
1831 ObjectMapper mapper = new ObjectMapper();
1832 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1834 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1835 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1836 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1840 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1841 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1842 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1843 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1845 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1846 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1847 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1848 .withStatus(HttpStatus.SC_OK)));
1850 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1851 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1852 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1853 .withStatus(HttpStatus.SC_OK)));
1855 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1856 "modelName=GR-API-DEFAULT&action=createInstance"))
1857 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1858 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1859 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1861 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1862 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
1865 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1866 RequestReferences requestReferences = new RequestReferences();
1867 requestReferences.setInstanceId("1882939");
1868 expectedResponse.setRequestReferences(requestReferences);
1870 ObjectMapper mapper = new ObjectMapper();
1871 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1873 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1874 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1875 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1879 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1880 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1881 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1882 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1884 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1885 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1888 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1889 RequestReferences requestReferences = new RequestReferences();
1890 requestReferences.setInstanceId("1882939");
1891 expectedResponse.setRequestReferences(requestReferences);
1893 ObjectMapper mapper = new ObjectMapper();
1894 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1896 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1900 public void createNetworkInstanceTestApiGrApi() throws IOException {
1901 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1902 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1903 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1905 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1906 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1907 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1908 .withStatus(HttpStatus.SC_OK)));
1910 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1911 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1912 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1913 .withStatus(HttpStatus.SC_OK)));
1915 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1916 "modelName=GR-API-DEFAULT&action=createInstance"))
1917 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1918 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1919 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1921 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1922 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
1925 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1926 RequestReferences requestReferences = new RequestReferences();
1927 requestReferences.setInstanceId("1882939");
1928 expectedResponse.setRequestReferences(requestReferences);
1930 ObjectMapper mapper = new ObjectMapper();
1931 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1933 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1934 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1935 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1939 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1940 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1941 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1942 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1944 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1945 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1946 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1947 .withStatus(HttpStatus.SC_OK)));
1949 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1950 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1951 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1952 .withStatus(HttpStatus.SC_OK)));
1954 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1955 "modelName=VNF-API-DEFAULT&action=createInstance"))
1956 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1957 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1958 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1960 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1961 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
1964 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1965 RequestReferences requestReferences = new RequestReferences();
1966 requestReferences.setInstanceId("1882939");
1967 expectedResponse.setRequestReferences(requestReferences);
1969 ObjectMapper mapper = new ObjectMapper();
1970 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1972 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1973 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1974 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1978 public void activateServiceInstanceRequestStatus() throws IOException{
1979 ServiceRecipe serviceRecipe = new ServiceRecipe();
1980 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1981 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1982 serviceRecipe.setAction(Action.createInstance.toString());
1983 serviceRecipe.setId(1);
1984 serviceRecipe.setRecipeTimeout(180);
1985 Service defaultService = new Service();
1986 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1988 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1989 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1990 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1991 HttpHeaders headers = new HttpHeaders();
1992 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
1994 stubFor(get(urlMatching(".*/service/.*"))
1995 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1996 .withBody(mapper.writeValueAsString(defaultService))
1997 .withStatus(HttpStatus.SC_OK)));
1999 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2000 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2001 .withBody(mapper.writeValueAsString(serviceRecipe))
2002 .withStatus(HttpStatus.SC_OK)));
2005 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2006 RequestReferences requestReferences = new RequestReferences();
2007 requestReferences.setInstanceId("1882939");
2008 expectedResponse.setRequestReferences(requestReferences);
2009 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2010 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2012 ObjectMapper mapper = new ObjectMapper();
2013 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2015 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2016 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2017 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2021 public void invalidRequestId() throws IOException {
2022 String illegalRequestId = "1234";
2023 HttpHeaders headers = new HttpHeaders();
2024 headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2026 uri = servInstanceuri + "v5/serviceInstances";
2027 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2029 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2030 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2033 public void invalidBPELResponse() throws IOException{
2035 ServiceRecipe serviceRecipe = new ServiceRecipe();
2036 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2037 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2038 serviceRecipe.setAction(Action.createInstance.toString());
2039 serviceRecipe.setId(1);
2040 serviceRecipe.setRecipeTimeout(180);
2041 Service defaultService = new Service();
2042 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2044 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2045 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2046 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2048 stubFor(get(urlMatching(".*/service/.*"))
2049 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2050 .withBody(mapper.writeValueAsString(defaultService))
2051 .withStatus(HttpStatus.SC_OK)));
2053 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2054 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2055 .withBody(mapper.writeValueAsString(serviceRecipe))
2056 .withStatus(HttpStatus.SC_OK)));
2058 uri = servInstanceuri + "v5/serviceInstances";
2059 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2061 ObjectMapper mapper = new ObjectMapper();
2062 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2063 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2065 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2066 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2067 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
2070 public void unauthorizedBPELResponse() throws IOException{
2072 ServiceRecipe serviceRecipe = new ServiceRecipe();
2073 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2074 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2075 serviceRecipe.setAction(Action.createInstance.toString());
2076 serviceRecipe.setId(1);
2077 serviceRecipe.setRecipeTimeout(180);
2078 Service defaultService = new Service();
2079 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2081 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2082 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2083 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2085 stubFor(get(urlMatching(".*/service/.*"))
2086 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2087 .withBody(mapper.writeValueAsString(defaultService))
2088 .withStatus(HttpStatus.SC_OK)));
2090 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2091 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2092 .withBody(mapper.writeValueAsString(serviceRecipe))
2093 .withStatus(HttpStatus.SC_OK)));
2095 uri = servInstanceuri + "v5/serviceInstances";
2096 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2098 ObjectMapper mapper = new ObjectMapper();
2099 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2100 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2102 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2103 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2104 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2108 public void invalidBPELResponse2() throws IOException{
2110 ServiceRecipe serviceRecipe = new ServiceRecipe();
2111 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2112 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2113 serviceRecipe.setAction(Action.createInstance.toString());
2114 serviceRecipe.setId(1);
2115 serviceRecipe.setRecipeTimeout(180);
2116 Service defaultService = new Service();
2117 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2119 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2120 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2121 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2123 stubFor(get(urlMatching(".*/service/.*"))
2124 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2125 .withBody(mapper.writeValueAsString(defaultService))
2126 .withStatus(HttpStatus.SC_OK)));
2128 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2129 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2130 .withBody(mapper.writeValueAsString(serviceRecipe))
2131 .withStatus(HttpStatus.SC_OK)));
2132 uri = servInstanceuri + "v5/serviceInstances";
2133 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2135 ObjectMapper mapper = new ObjectMapper();
2136 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2137 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2139 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2140 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2141 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2145 public void createMacroServiceInstance() throws IOException{
2146 ServiceRecipe serviceRecipe = new ServiceRecipe();
2147 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2148 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2149 serviceRecipe.setAction(Action.createInstance.toString());
2150 serviceRecipe.setId(1);
2151 serviceRecipe.setRecipeTimeout(180);
2152 Service defaultService = new Service();
2153 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2155 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2156 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2157 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2159 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2160 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2161 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2163 stubFor(get(urlMatching(".*/service/.*"))
2164 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2165 .withBody(mapper.writeValueAsString(defaultService))
2166 .withStatus(HttpStatus.SC_OK)));
2168 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2169 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2170 .withBody(mapper.writeValueAsString(serviceRecipe))
2171 .withStatus(HttpStatus.SC_OK)));
2174 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2175 RequestReferences requestReferences = new RequestReferences();
2176 requestReferences.setInstanceId("1882939");
2177 expectedResponse.setRequestReferences(requestReferences);
2178 uri = servInstanceUriPrev7 + "v5";
2179 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
2181 ObjectMapper mapper = new ObjectMapper();
2182 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2185 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2186 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2187 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2191 public void testUserParams() throws IOException {
2192 ObjectMapper mapper = new ObjectMapper();
2193 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2194 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2195 String userParamsTxt = inputStream("/userParams.txt");
2197 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2198 System.out.println(userParams);
2199 assertTrue(userParams.size() > 0);
2200 assertTrue(userParams.get(0).containsKey("name"));
2201 assertTrue(userParams.get(0).containsKey("value"));
2202 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2206 public void testConfigureCloudConfig() throws IOException {
2207 ObjectMapper mapper = new ObjectMapper();
2208 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2209 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2211 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2212 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2216 public void testMapToLegacyRequest() throws IOException {
2217 ObjectMapper mapper = new ObjectMapper();
2218 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2219 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2220 servInstances.mapToLegacyRequest(request.getRequestDetails());
2221 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2222 assertThat(request, sameBeanAs(expected));
2225 public void scaleOutVfModule() throws IOException {
2226 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2227 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2228 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2230 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2231 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2232 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2233 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2235 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2236 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2237 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2238 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2240 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2241 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2242 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2243 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2246 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2247 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2248 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2249 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2251 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2252 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2253 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2256 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2257 RequestReferences requestReferences = new RequestReferences();
2258 requestReferences.setInstanceId("1882939");
2259 expectedResponse.setRequestReferences(requestReferences);
2260 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2261 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST);
2263 ObjectMapper mapper = new ObjectMapper();
2264 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2266 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2267 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2268 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2269 assertTrue(response.getBody().contains("1882939"));
2272 public void createServiceInstanceBadResponse() throws IOException{
2273 ServiceRecipe serviceRecipe = new ServiceRecipe();
2274 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2275 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2276 serviceRecipe.setAction(Action.createInstance.toString());
2277 serviceRecipe.setId(1);
2278 serviceRecipe.setRecipeTimeout(180);
2279 Service defaultService = new Service();
2280 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2282 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2283 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2284 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2286 stubFor(get(urlMatching(".*/service/.*"))
2287 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2288 .withBody(mapper.writeValueAsString(defaultService))
2289 .withStatus(HttpStatus.SC_OK)));
2291 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2292 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2293 .withBody(mapper.writeValueAsString(serviceRecipe))
2294 .withStatus(HttpStatus.SC_OK)));
2296 uri = servInstanceuri + "v5/serviceInstances";
2297 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2299 ObjectMapper mapper = new ObjectMapper();
2300 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2301 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2303 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2304 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2305 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2308 public void createServiceInstanceDuplicateError() throws IOException{
2309 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2310 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2311 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2313 uri = servInstanceuri + "v5/serviceInstances";
2314 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2316 ObjectMapper mapper = new ObjectMapper();
2317 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2318 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2320 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2321 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2322 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2325 public void createServiceInstanceSaveError() throws IOException{
2326 ServiceRecipe serviceRecipe = new ServiceRecipe();
2327 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2328 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2329 serviceRecipe.setAction(Action.createInstance.toString());
2330 serviceRecipe.setId(1);
2331 serviceRecipe.setRecipeTimeout(180);
2332 Service defaultService = new Service();
2333 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2334 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2335 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2336 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2337 stubFor(get(urlMatching(".*/service/.*"))
2338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2339 .withBody(mapper.writeValueAsString(defaultService))
2340 .withStatus(HttpStatus.SC_OK)));
2342 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2343 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2344 .withBody(mapper.writeValueAsString(serviceRecipe))
2345 .withStatus(HttpStatus.SC_OK)));
2347 uri = servInstanceuri + "v5/serviceInstances";
2348 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2350 ObjectMapper mapper = new ObjectMapper();
2351 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2352 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2354 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2355 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2356 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2359 public void createPortConfigurationSaveError() throws IOException {
2360 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2361 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2362 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2363 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2365 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2367 HttpHeaders headers = new HttpHeaders();
2369 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2370 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2372 ObjectMapper mapper = new ObjectMapper();
2373 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2374 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2376 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2377 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2378 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2381 public void createPortConfigDbUpdateError() throws IOException {
2382 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2383 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2384 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2386 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2387 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
2389 ObjectMapper mapper = new ObjectMapper();
2390 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2391 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2393 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2394 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2395 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2398 public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
2399 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2400 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2401 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2403 stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2404 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2405 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2406 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2408 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
2409 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2410 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2411 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2413 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
2414 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2415 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2416 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2417 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2418 HttpHeaders headers = new HttpHeaders();
2419 headers.set(MsoLogger.CLIENT_ID, "VID");
2421 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2422 RequestReferences requestReferences = new RequestReferences();
2423 requestReferences.setInstanceId("1882939");
2424 expectedResponse.setRequestReferences(requestReferences);
2425 uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2426 ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2428 ObjectMapper mapper = new ObjectMapper();
2429 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2432 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2433 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2434 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2437 public void createInstanceGroup() throws IOException{
2438 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2439 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2440 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2442 HttpHeaders headers = new HttpHeaders();
2444 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2445 RequestReferences requestReferences = new RequestReferences();
2446 requestReferences.setInstanceId("1882939");
2447 expectedResponse.setRequestReferences(requestReferences);
2448 uri = servInstanceuri + "/v7/instanceGroups";
2449 ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2451 ObjectMapper mapper = new ObjectMapper();
2452 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2455 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2456 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2457 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2460 public void deleteInstanceGroup() throws IOException{
2461 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2462 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2463 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2465 HttpHeaders headers = new HttpHeaders();
2466 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2467 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
2468 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
2470 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2471 RequestReferences requestReferences = new RequestReferences();
2472 requestReferences.setInstanceId("1882939");
2473 expectedResponse.setRequestReferences(requestReferences);
2474 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2475 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2477 ObjectMapper mapper = new ObjectMapper();
2478 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2481 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2482 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2483 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2486 public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
2487 HttpHeaders headers = new HttpHeaders();
2488 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
2489 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
2490 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2491 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2493 ObjectMapper mapper = new ObjectMapper();
2494 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2495 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2498 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2499 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2500 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2503 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
2504 HttpHeaders headers = new HttpHeaders();
2505 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2506 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
2507 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2508 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2510 ObjectMapper mapper = new ObjectMapper();
2511 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2512 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2515 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2516 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2517 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2520 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException{
2521 HttpHeaders headers = new HttpHeaders();
2522 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2523 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2525 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2526 RequestReferences requestReferences = new RequestReferences();
2527 requestReferences.setInstanceId("1882939");
2528 expectedResponse.setRequestReferences(requestReferences);
2529 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2530 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2532 ObjectMapper mapper = new ObjectMapper();
2533 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2534 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2537 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2538 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2539 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2542 public void addMembers() throws IOException{
2543 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2544 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2545 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2546 HttpHeaders headers = new HttpHeaders();
2548 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2549 RequestReferences requestReferences = new RequestReferences();
2550 requestReferences.setInstanceId("1882939");
2551 expectedResponse.setRequestReferences(requestReferences);
2552 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2553 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2555 ObjectMapper mapper = new ObjectMapper();
2556 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2559 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2560 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2561 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2564 public void removeMembers() throws IOException{
2565 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2566 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2567 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2568 HttpHeaders headers = new HttpHeaders();
2570 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2571 RequestReferences requestReferences = new RequestReferences();
2572 requestReferences.setInstanceId("1882939");
2573 expectedResponse.setRequestReferences(requestReferences);
2574 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2575 ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2577 ObjectMapper mapper = new ObjectMapper();
2578 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2581 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2582 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2583 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));