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.LogConstants;
56 import org.onap.so.logger.MsoLogger;
57 import org.onap.so.serviceinstancebeans.CloudConfiguration;
58 import org.onap.so.serviceinstancebeans.ModelInfo;
59 import org.onap.so.serviceinstancebeans.RequestError;
60 import org.onap.so.serviceinstancebeans.RequestParameters;
61 import org.onap.so.serviceinstancebeans.RequestReferences;
62 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
63 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
65 import org.springframework.beans.factory.annotation.Autowired;
66 import org.springframework.beans.factory.annotation.Value;
67 import org.springframework.http.HttpEntity;
68 import org.springframework.http.HttpHeaders;
69 import org.springframework.http.HttpMethod;
70 import org.springframework.http.ResponseEntity;
71 import org.springframework.util.ResourceUtils;
72 import org.springframework.web.util.UriComponentsBuilder;
74 import com.fasterxml.jackson.annotation.JsonInclude.Include;
75 import com.fasterxml.jackson.databind.DeserializationFeature;
76 import com.fasterxml.jackson.databind.ObjectMapper;
77 import com.github.tomakehurst.wiremock.http.Fault;
79 import ch.qos.logback.classic.spi.ILoggingEvent;
82 public class ServiceInstancesTest extends BaseTest{
84 private final ObjectMapper mapper = new ObjectMapper();
87 private ServiceInstances servInstances;
89 @Value("${wiremock.server.port}")
90 private String wiremockPort;
92 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
93 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
97 public void beforeClass() {
98 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
99 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
100 .withStatus(HttpStatus.SC_OK)));
103 public String inputStream(String JsonInput)throws IOException{
104 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
105 return new String(Files.readAllBytes(Paths.get(JsonInput)));
108 private String getWiremockResponseForCatalogdb(String file) {
110 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
111 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
112 } catch (IOException e) {
119 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
121 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
122 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
124 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
125 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
128 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
130 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
132 return restTemplate.exchange(builder.toUriString(),
133 reqMethod, request, String.class);
136 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
137 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
141 public void test_mapJSONtoMSOStyle() throws IOException{
142 ObjectMapper mapper = new ObjectMapper();
143 mapper.setSerializationInclusion(Include.NON_NULL);
144 String testRequest= inputStream("/ServiceInstanceDefault.json");
145 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
146 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
147 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
148 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
149 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
150 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
151 assertEquals("10",modelInfo.getModelUuid());
155 public void createServiceInstanceVIDDefault() throws IOException{
156 TestAppender.events.clear();
158 ServiceRecipe serviceRecipe = new ServiceRecipe();
159 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
160 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
161 serviceRecipe.setAction(Action.createInstance.toString());
162 serviceRecipe.setId(1);
163 serviceRecipe.setRecipeTimeout(180);
164 Service defaultService = new Service();
165 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
168 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
169 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
170 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
172 stubFor(get(urlMatching(".*/service/search/.*"))
173 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
174 .withBody(mapper.writeValueAsString(defaultService))
175 .withStatus(HttpStatus.SC_OK)));
177 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
178 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
179 .withBody(mapper.writeValueAsString(serviceRecipe))
180 .withStatus(HttpStatus.SC_OK)));
181 HttpHeaders headers = new HttpHeaders();
182 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
183 headers.set(MsoLogger.CLIENT_ID, "VID");
185 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
186 RequestReferences requestReferences = new RequestReferences();
187 requestReferences.setInstanceId("1882939");
188 expectedResponse.setRequestReferences(requestReferences);
189 uri = servInstanceuri + "v5/serviceInstances";
190 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
192 ObjectMapper mapper = new ObjectMapper();
193 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
196 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
197 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
198 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
202 for(ILoggingEvent logEvent : TestAppender.events)
203 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
204 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
206 Map<String,String> mdc = logEvent.getMDCPropertyMap();
207 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
208 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
209 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
210 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
211 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
212 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
213 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
214 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
215 Map<String,String> mdc = logEvent.getMDCPropertyMap();
216 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
217 assertNotNull(mdc.get(MsoLogger.ENDTIME));
218 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
219 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
220 assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
221 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
222 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
223 assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
224 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
225 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
226 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
227 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
231 public void createServiceInstanceServiceInstancesUri() throws IOException{
232 ServiceRecipe serviceRecipe = new ServiceRecipe();
233 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
234 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
235 serviceRecipe.setAction(Action.createInstance.toString());
236 serviceRecipe.setId(1);
237 serviceRecipe.setRecipeTimeout(180);
238 Service defaultService = new Service();
239 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
241 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
242 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
243 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
246 stubFor(get(urlMatching(".*/service/search/.*"))
247 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
248 .withBody(mapper.writeValueAsString(defaultService))
249 .withStatus(HttpStatus.SC_OK)));
251 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
252 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
253 .withBody(mapper.writeValueAsString(serviceRecipe))
254 .withStatus(HttpStatus.SC_OK)));
257 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
258 RequestReferences requestReferences = new RequestReferences();
259 requestReferences.setInstanceId("1882939");
260 expectedResponse.setRequestReferences(requestReferences);
261 uri = servInstanceUriPrev7 + "v5";
262 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
264 ObjectMapper mapper = new ObjectMapper();
265 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
268 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
269 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
270 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
273 public void createServiceInstanceBpelStatusError() throws IOException{
274 ServiceRecipe serviceRecipe = new ServiceRecipe();
275 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
276 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
277 serviceRecipe.setAction(Action.createInstance.toString());
278 serviceRecipe.setId(1);
279 serviceRecipe.setRecipeTimeout(180);
280 Service defaultService = new Service();
281 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
284 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
286 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
289 stubFor(get(urlMatching(".*/service/search/.*"))
290 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
291 .withBody(mapper.writeValueAsString(defaultService))
292 .withStatus(HttpStatus.SC_OK)));
294 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
295 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
296 .withBody(mapper.writeValueAsString(serviceRecipe))
297 .withStatus(HttpStatus.SC_OK)));
299 uri = servInstanceuri + "v5/serviceInstances";
300 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
302 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
305 public void createServiceInstanceBadGateway() throws IOException{
306 ServiceRecipe serviceRecipe = new ServiceRecipe();
307 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
308 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
309 serviceRecipe.setAction(Action.createInstance.toString());
310 serviceRecipe.setId(1);
311 serviceRecipe.setRecipeTimeout(180);
312 Service defaultService = new Service();
313 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
315 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
316 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
318 stubFor(get(urlMatching(".*/service/search/.*"))
319 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
320 .withBody(mapper.writeValueAsString(defaultService))
321 .withStatus(HttpStatus.SC_OK)));
323 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
324 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
325 .withBody(mapper.writeValueAsString(serviceRecipe))
326 .withStatus(HttpStatus.SC_OK)));
328 uri = servInstanceuri + "v5/serviceInstances";
329 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
331 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
334 public void createServiceInstanceEmptyResponse() throws IOException{
335 ServiceRecipe serviceRecipe = new ServiceRecipe();
336 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
337 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
338 serviceRecipe.setAction(Action.createInstance.toString());
339 serviceRecipe.setId(1);
340 serviceRecipe.setRecipeTimeout(180);
341 Service defaultService = new Service();
342 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
344 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
345 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
347 stubFor(get(urlMatching(".*/service/search/.*"))
348 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
349 .withBody(mapper.writeValueAsString(defaultService))
350 .withStatus(HttpStatus.SC_OK)));
352 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
353 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
354 .withBody(mapper.writeValueAsString(serviceRecipe))
355 .withStatus(HttpStatus.SC_OK)));
357 uri = servInstanceuri + "v5/serviceInstances";
358 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
360 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
363 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
364 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
365 HttpHeaders headers = new HttpHeaders();
366 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
367 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, headers);
369 Service defaultService = new Service();
370 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
372 stubFor(get(urlMatching(".*/service/search/.*"))
373 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
374 .withBody(mapper.writeValueAsString(defaultService))
375 .withStatus(HttpStatus.SC_OK)));
378 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
379 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
380 .withStatus(HttpStatus.SC_NOT_FOUND)));
382 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
385 public void activateServiceInstanceNoRecipe() throws IOException{
386 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
387 Service defaultService = new Service();
388 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
389 stubFor(get(urlMatching(".*/service/search/.*"))
390 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
391 .withBody(mapper.writeValueAsString(defaultService))
392 .withStatus(HttpStatus.SC_OK)));
394 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
395 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
396 .withStatus(HttpStatus.SC_NOT_FOUND)));
398 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
400 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
403 public void activateServiceInstance() throws IOException{
404 ServiceRecipe serviceRecipe = new ServiceRecipe();
405 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
406 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
407 serviceRecipe.setAction(Action.createInstance.toString());
408 serviceRecipe.setId(1);
409 serviceRecipe.setRecipeTimeout(180);
410 Service defaultService = new Service();
411 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
413 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
414 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
415 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
417 stubFor(get(urlMatching(".*/service/search/.*"))
418 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
419 .withBody(mapper.writeValueAsString(defaultService))
420 .withStatus(HttpStatus.SC_OK)));
422 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
423 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
424 .withBody(mapper.writeValueAsString(serviceRecipe))
425 .withStatus(HttpStatus.SC_OK)));
426 HttpHeaders headers = new HttpHeaders();
427 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
429 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
430 RequestReferences requestReferences = new RequestReferences();
431 requestReferences.setInstanceId("1882939");
432 expectedResponse.setRequestReferences(requestReferences);
433 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
434 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
436 ObjectMapper mapper = new ObjectMapper();
437 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
439 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
440 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
441 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
444 public void deactivateServiceInstance() throws IOException{
446 ServiceRecipe serviceRecipe = new ServiceRecipe();
447 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
448 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
449 serviceRecipe.setAction(Action.createInstance.toString());
450 serviceRecipe.setId(1);
451 serviceRecipe.setRecipeTimeout(180);
452 Service defaultService = new Service();
453 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
455 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
456 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
457 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
459 stubFor(get(urlMatching(".*/service/.*"))
460 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
461 .withBody(mapper.writeValueAsString(defaultService))
462 .withStatus(HttpStatus.SC_OK)));
464 stubFor(get(urlMatching(".*/service/search/.*"))
465 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
466 .withBody(mapper.writeValueAsString(defaultService))
467 .withStatus(HttpStatus.SC_OK)));
469 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
470 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
471 .withBody(mapper.writeValueAsString(serviceRecipe))
472 .withStatus(HttpStatus.SC_OK)));
475 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
476 RequestReferences requestReferences = new RequestReferences();
477 requestReferences.setInstanceId("1882939");
478 expectedResponse.setRequestReferences(requestReferences);
479 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
480 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
482 ObjectMapper mapper = new ObjectMapper();
483 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
485 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
486 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
487 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
490 public void deleteServiceInstance() throws IOException {
491 ServiceRecipe serviceRecipe = new ServiceRecipe();
492 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
493 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
494 serviceRecipe.setAction(Action.createInstance.toString());
495 serviceRecipe.setId(1);
496 serviceRecipe.setRecipeTimeout(180);
497 Service defaultService = new Service();
498 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
500 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
501 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
502 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
504 stubFor(get(urlMatching(".*/service/.*"))
505 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
506 .withBody(mapper.writeValueAsString(defaultService))
507 .withStatus(HttpStatus.SC_OK)));
509 stubFor(get(urlMatching(".*/service/search/.*"))
510 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
511 .withBody(mapper.writeValueAsString(defaultService))
512 .withStatus(HttpStatus.SC_OK)));
514 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
515 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
516 .withBody(mapper.writeValueAsString(serviceRecipe))
517 .withStatus(HttpStatus.SC_OK)));
519 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
520 RequestReferences requestReferences = new RequestReferences();
521 requestReferences.setInstanceId("1882939");
522 expectedResponse.setRequestReferences(requestReferences);
523 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
524 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
526 ObjectMapper mapper = new ObjectMapper();
527 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
529 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
530 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
531 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
534 public void assignServiceInstance() throws IOException {
535 ServiceRecipe serviceRecipe = new ServiceRecipe();
536 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
537 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
538 serviceRecipe.setAction(Action.createInstance.toString());
539 serviceRecipe.setId(1);
540 serviceRecipe.setRecipeTimeout(180);
541 Service defaultService = new Service();
542 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
544 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
545 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
546 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
548 stubFor(get(urlMatching(".*/service/.*"))
549 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
550 .withBody(mapper.writeValueAsString(defaultService))
551 .withStatus(HttpStatus.SC_OK)));
553 stubFor(get(urlMatching(".*/service/search/.*"))
554 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
555 .withBody(mapper.writeValueAsString(defaultService))
556 .withStatus(HttpStatus.SC_OK)));
558 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
559 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
560 .withBody(mapper.writeValueAsString(serviceRecipe))
561 .withStatus(HttpStatus.SC_OK)));
563 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
564 RequestReferences requestReferences = new RequestReferences();
565 requestReferences.setInstanceId("1882939");
566 expectedResponse.setRequestReferences(requestReferences);
567 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
568 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
570 ObjectMapper mapper = new ObjectMapper();
571 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
573 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
574 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
575 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
579 public void unassignServiceInstance() throws IOException {
580 ServiceRecipe serviceRecipe = new ServiceRecipe();
581 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
582 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
583 serviceRecipe.setAction(Action.createInstance.toString());
584 serviceRecipe.setId(1);
585 serviceRecipe.setRecipeTimeout(180);
586 Service defaultService = new Service();
587 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
589 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
590 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
591 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
593 stubFor(get(urlMatching(".*/service/.*"))
594 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
595 .withBody(mapper.writeValueAsString(defaultService))
596 .withStatus(HttpStatus.SC_OK)));
598 stubFor(get(urlMatching(".*/service/search/.*"))
599 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
600 .withBody(mapper.writeValueAsString(defaultService))
601 .withStatus(HttpStatus.SC_OK)));
603 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
604 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
605 .withBody(mapper.writeValueAsString(serviceRecipe))
606 .withStatus(HttpStatus.SC_OK)));
608 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
609 RequestReferences requestReferences = new RequestReferences();
610 requestReferences.setInstanceId("1882939");
611 expectedResponse.setRequestReferences(requestReferences);
612 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
613 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
615 ObjectMapper mapper = new ObjectMapper();
616 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
618 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
619 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
620 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
623 public void createPortConfiguration() throws IOException {
624 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
625 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
626 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
627 HttpHeaders headers = new HttpHeaders();
628 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
630 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
631 RequestReferences requestReferences = new RequestReferences();
632 requestReferences.setInstanceId("1882939");
633 expectedResponse.setRequestReferences(requestReferences);
634 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
635 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
637 ObjectMapper mapper = new ObjectMapper();
638 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
640 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
641 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
642 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
643 assertTrue(response.getBody().contains("1882939"));
646 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
647 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
648 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
650 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
653 public void deletePortConfiguration() throws IOException {
654 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
656 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
658 HttpHeaders headers = new HttpHeaders();
659 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
661 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
662 RequestReferences requestReferences = new RequestReferences();
663 requestReferences.setInstanceId("1882939");
664 expectedResponse.setRequestReferences(requestReferences);
665 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
666 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
668 ObjectMapper mapper = new ObjectMapper();
669 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
671 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
672 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
673 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
676 public void enablePort() throws IOException {
677 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
678 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
679 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
681 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
682 RequestReferences requestReferences = new RequestReferences();
683 requestReferences.setInstanceId("1882939");
684 expectedResponse.setRequestReferences(requestReferences);
685 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
686 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
688 ObjectMapper mapper = new ObjectMapper();
689 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
691 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
692 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
693 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
696 public void disablePort() throws IOException {
697 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
698 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
699 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
701 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
702 RequestReferences requestReferences = new RequestReferences();
703 requestReferences.setInstanceId("1882939");
704 expectedResponse.setRequestReferences(requestReferences);
705 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
706 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
708 ObjectMapper mapper = new ObjectMapper();
709 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
711 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
712 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
713 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
716 public void activatePort() throws IOException {
717 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
718 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
719 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
721 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
722 RequestReferences requestReferences = new RequestReferences();
723 requestReferences.setInstanceId("1882939");
724 expectedResponse.setRequestReferences(requestReferences);
725 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
726 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
728 ObjectMapper mapper = new ObjectMapper();
729 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
731 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
732 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
733 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
736 public void deactivatePort() throws IOException {
737 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
738 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
739 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
741 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
742 RequestReferences requestReferences = new RequestReferences();
743 requestReferences.setInstanceId("1882939");
744 expectedResponse.setRequestReferences(requestReferences);
745 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
746 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
748 ObjectMapper mapper = new ObjectMapper();
749 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
751 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
752 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
753 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
756 public void addRelationships() throws IOException {
757 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
758 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
759 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
762 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
763 RequestReferences requestReferences = new RequestReferences();
764 requestReferences.setInstanceId("1882939");
765 expectedResponse.setRequestReferences(requestReferences);
766 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
767 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
769 ObjectMapper mapper = new ObjectMapper();
770 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
772 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
773 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
774 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
777 public void removeRelationships() throws IOException {
778 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
779 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
780 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
783 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
784 RequestReferences requestReferences = new RequestReferences();
785 requestReferences.setInstanceId("1882939");
786 expectedResponse.setRequestReferences(requestReferences);
787 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
788 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
790 ObjectMapper mapper = new ObjectMapper();
791 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
793 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
794 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
795 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
798 public void createVnfInstanceNoALaCarte() throws IOException {
799 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
800 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
801 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
804 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
805 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
806 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
807 .withStatus(org.apache.http.HttpStatus.SC_OK)));
809 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
810 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
811 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
812 .withStatus(org.apache.http.HttpStatus.SC_OK)));
814 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
815 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
816 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
817 .withStatus(org.apache.http.HttpStatus.SC_OK)));
820 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
821 RequestReferences requestReferences = new RequestReferences();
822 requestReferences.setInstanceId("1882939");
823 expectedResponse.setRequestReferences(requestReferences);
824 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
825 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
827 ObjectMapper mapper = new ObjectMapper();
828 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
830 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
831 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
832 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
835 public void createVnfInstance() throws IOException {
836 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
837 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
838 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
840 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
841 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
842 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
843 .withStatus(org.apache.http.HttpStatus.SC_OK)));
844 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
846 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
847 .withStatus(org.apache.http.HttpStatus.SC_OK)));
850 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
851 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
852 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
853 .withStatus(org.apache.http.HttpStatus.SC_OK)));
855 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
856 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
857 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
858 .withStatus(org.apache.http.HttpStatus.SC_OK)));
860 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
861 HttpHeaders headers = new HttpHeaders();
862 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
864 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
865 RequestReferences requestReferences = new RequestReferences();
866 requestReferences.setInstanceId("1882939");
867 expectedResponse.setRequestReferences(requestReferences);
868 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
869 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
871 ObjectMapper mapper = new ObjectMapper();
872 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
874 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
875 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
876 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
877 assertTrue(response.getBody().contains("1882939"));
880 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
881 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
882 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
884 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
887 public void createVnfInstanceInvalidVnfResource() throws IOException {
888 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
889 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
891 ObjectMapper mapper = new ObjectMapper();
892 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
893 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
895 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
896 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
897 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
900 public void replaceVnfInstance() throws IOException {
901 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
902 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
903 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
905 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
906 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
907 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
908 .withStatus(org.apache.http.HttpStatus.SC_OK)));
910 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
911 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
912 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
913 .withStatus(org.apache.http.HttpStatus.SC_OK)));
915 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
916 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
917 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
918 .withStatus(org.apache.http.HttpStatus.SC_OK)));
920 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
921 RequestReferences requestReferences = new RequestReferences();
922 requestReferences.setInstanceId("1882939");
923 expectedResponse.setRequestReferences(requestReferences);
924 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
925 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
927 ObjectMapper mapper = new ObjectMapper();
928 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
930 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
931 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
932 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
935 public void replaceVnfRecreateInstance() throws IOException {
936 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
937 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
938 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
940 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
941 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
942 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
943 .withStatus(org.apache.http.HttpStatus.SC_OK)));
945 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
946 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
947 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
948 .withStatus(org.apache.http.HttpStatus.SC_OK)));
950 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
951 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
952 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
953 .withStatus(org.apache.http.HttpStatus.SC_OK)));
956 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
957 RequestReferences requestReferences = new RequestReferences();
958 requestReferences.setInstanceId("1882939");
959 expectedResponse.setRequestReferences(requestReferences);
960 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
961 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
962 logger.debug(response.getBody());
963 ObjectMapper mapper = new ObjectMapper();
964 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
966 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
967 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
968 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
971 public void recreateVnfInstance() throws IOException {
972 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
973 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
974 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
976 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
977 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
978 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
979 .withStatus(org.apache.http.HttpStatus.SC_OK)));
981 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
982 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
983 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
984 .withStatus(org.apache.http.HttpStatus.SC_OK)));
986 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
987 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
988 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
989 .withStatus(org.apache.http.HttpStatus.SC_OK)));
992 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
993 RequestReferences requestReferences = new RequestReferences();
994 requestReferences.setInstanceId("1882939");
995 expectedResponse.setRequestReferences(requestReferences);
996 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
997 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST);
998 logger.debug(response.getBody());
999 ObjectMapper mapper = new ObjectMapper();
1000 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1002 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1003 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1004 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1007 public void updateVnfInstance() throws IOException {
1008 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1009 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1010 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1012 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
1013 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1014 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1015 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1017 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
1018 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1019 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1020 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1022 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1023 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1024 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1025 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1026 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1029 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1030 RequestReferences requestReferences = new RequestReferences();
1031 requestReferences.setInstanceId("1882939");
1032 expectedResponse.setRequestReferences(requestReferences);
1033 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1034 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
1036 ObjectMapper mapper = new ObjectMapper();
1037 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1039 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1040 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1041 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1044 public void applyUpdatedConfig() throws IOException {
1045 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1046 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1047 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1050 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1051 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1052 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1053 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1054 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1056 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
1057 HttpHeaders headers = new HttpHeaders();
1058 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1060 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1061 RequestReferences requestReferences = new RequestReferences();
1062 requestReferences.setInstanceId("1882939");
1063 expectedResponse.setRequestReferences(requestReferences);
1064 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1065 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1067 ObjectMapper mapper = new ObjectMapper();
1068 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1070 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1071 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1072 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1075 public void deleteVnfInstanceV5() throws IOException {
1076 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1077 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1078 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1080 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1081 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1082 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1083 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1084 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1086 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1087 RequestReferences requestReferences = new RequestReferences();
1088 requestReferences.setInstanceId("1882939");
1089 expectedResponse.setRequestReferences(requestReferences);
1090 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1091 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
1093 ObjectMapper mapper = new ObjectMapper();
1094 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1096 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1097 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1098 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1101 public void createVfModuleInstance() throws IOException {
1103 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1104 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1105 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1106 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1108 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1109 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1110 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1111 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1113 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1114 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1115 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1116 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1118 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1119 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1120 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1122 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1123 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1124 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1125 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1126 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1128 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1129 RequestReferences requestReferences = new RequestReferences();
1130 requestReferences.setInstanceId("1882939");
1131 expectedResponse.setRequestReferences(requestReferences);
1132 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1133 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
1135 ObjectMapper mapper = new ObjectMapper();
1136 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1138 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1139 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1140 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1141 assertTrue(response.getBody().contains("1882939"));
1144 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1145 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1146 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1147 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1149 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1150 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1151 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1152 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1154 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1155 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1156 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1157 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1158 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1160 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1161 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1162 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1163 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1165 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1166 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1167 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1168 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1169 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1171 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1172 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1173 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1174 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1176 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1177 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1178 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1179 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1182 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1183 "[?]vnfComponentType=vfModule&action=createInstance"))
1184 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1185 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1186 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1189 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1190 RequestReferences requestReferences = new RequestReferences();
1191 requestReferences.setInstanceId("1882939");
1192 expectedResponse.setRequestReferences(requestReferences);
1193 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1194 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
1195 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1196 ObjectMapper mapper = new ObjectMapper();
1197 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1198 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1201 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1202 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1204 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1206 stubFor(get(urlMatching(".*/vnfResource/.*"))
1207 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1208 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1209 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1211 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1212 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1213 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1214 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1216 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1217 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1218 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1219 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1221 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1222 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1223 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1224 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1226 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1227 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1228 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1229 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1231 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1232 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1233 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1234 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1236 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1237 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1239 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1240 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1243 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1244 RequestReferences requestReferences = new RequestReferences();
1245 requestReferences.setInstanceId("1882939");
1246 expectedResponse.setRequestReferences(requestReferences);
1247 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1248 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
1250 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1251 ObjectMapper mapper = new ObjectMapper();
1252 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1253 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1256 public void createVfModuleInstanceNoRecipe() throws IOException {
1258 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1259 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1260 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1261 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1263 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1264 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1265 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1266 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1267 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1269 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1270 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1271 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1272 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1274 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1275 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1276 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1277 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1278 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1280 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1281 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
1283 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1284 ObjectMapper mapper = new ObjectMapper();
1285 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1286 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1287 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1290 public void replaceVfModuleInstance() throws IOException {
1291 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1292 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1293 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1295 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1296 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1297 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1298 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1299 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1301 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1302 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1303 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1304 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1305 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1307 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1308 RequestReferences requestReferences = new RequestReferences();
1309 requestReferences.setInstanceId("1882939");
1310 expectedResponse.setRequestReferences(requestReferences);
1311 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1312 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
1314 ObjectMapper mapper = new ObjectMapper();
1315 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1317 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1318 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1319 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1322 public void updateVfModuleInstance() throws IOException {
1323 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1324 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1325 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1327 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1328 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1329 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1330 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1332 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1333 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1334 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1335 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1337 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1339 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1340 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1342 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1343 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1344 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1345 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1346 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1349 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1350 RequestReferences requestReferences = new RequestReferences();
1351 requestReferences.setInstanceId("1882939");
1352 expectedResponse.setRequestReferences(requestReferences);
1353 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1354 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
1355 logger.debug(response.getBody());
1357 ObjectMapper mapper = new ObjectMapper();
1358 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1360 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1361 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1362 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1365 public void createVfModuleNoModelType() throws IOException{
1366 HttpHeaders headers = new HttpHeaders();
1367 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1368 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1369 expectedRecord.setRequestStatus("FAILED");
1370 expectedRecord.setAction("createInstance");
1371 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1372 expectedRecord.setProgress(100L);
1373 expectedRecord.setSource("VID");
1374 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1375 expectedRecord.setLastModifiedBy("APIH");
1376 expectedRecord.setVfModuleName("testVfModule2");
1377 expectedRecord.setVfModuleModelName("serviceModel");
1378 expectedRecord.setRequestScope("vfModule");
1379 expectedRecord.setRequestAction("createInstance");
1380 expectedRecord.setRequestorId("zz9999");
1381 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1382 //VnfType is not sent in this request, should be blank in db
1383 expectedRecord.setVnfType("");
1384 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1386 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1388 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1391 public void inPlaceSoftwareUpdate() throws IOException {
1392 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1393 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1394 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1396 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1397 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1398 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1399 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1400 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1403 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1404 RequestReferences requestReferences = new RequestReferences();
1405 requestReferences.setInstanceId("1882939");
1406 expectedResponse.setRequestReferences(requestReferences);
1407 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1408 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
1410 ObjectMapper mapper = new ObjectMapper();
1411 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1413 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1414 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1415 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1419 public void deleteVfModuleInstance() throws IOException {
1420 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1421 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1422 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1424 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1425 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1426 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1427 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1428 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1430 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1431 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1432 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1433 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1434 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1437 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1438 RequestReferences requestReferences = new RequestReferences();
1439 requestReferences.setInstanceId("1882939");
1440 expectedResponse.setRequestReferences(requestReferences);
1441 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1442 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
1444 ObjectMapper mapper = new ObjectMapper();
1445 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1447 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1448 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1449 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1452 public void deleteVfModuleNoModelInvariantId() throws IOException {
1453 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1454 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1455 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1457 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1458 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1459 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1460 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1461 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1464 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1465 RequestReferences requestReferences = new RequestReferences();
1466 requestReferences.setInstanceId("1882939");
1467 expectedResponse.setRequestReferences(requestReferences);
1468 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1469 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE);
1471 ObjectMapper mapper = new ObjectMapper();
1472 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1474 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1475 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1476 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1479 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1480 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1481 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1482 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1484 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1485 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1487 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1488 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1490 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1491 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1492 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1493 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1494 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1497 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1498 RequestReferences requestReferences = new RequestReferences();
1499 requestReferences.setInstanceId("1882939");
1500 expectedResponse.setRequestReferences(requestReferences);
1501 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1502 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
1504 ObjectMapper mapper = new ObjectMapper();
1505 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1507 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1508 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1509 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1512 public void createVolumeGroupInstance() throws IOException {
1513 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1514 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1515 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1517 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1518 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1519 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1520 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1522 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1523 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1524 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1525 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1527 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1528 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1530 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1531 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1534 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1535 RequestReferences requestReferences = new RequestReferences();
1536 requestReferences.setInstanceId("1882939");
1537 expectedResponse.setRequestReferences(requestReferences);
1538 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1539 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
1541 ObjectMapper mapper = new ObjectMapper();
1542 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1544 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1545 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1546 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1547 assertTrue(response.getBody().contains("1882939"));
1550 public void updateVolumeGroupInstance() throws IOException {
1551 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1552 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1553 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1555 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1556 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1557 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1558 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1560 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1561 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1562 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1563 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1565 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1566 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1567 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1568 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1569 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1572 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1573 RequestReferences requestReferences = new RequestReferences();
1574 requestReferences.setInstanceId("1882939");
1575 expectedResponse.setRequestReferences(requestReferences);
1576 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1577 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
1579 ObjectMapper mapper = new ObjectMapper();
1580 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1582 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1583 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1584 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1587 public void deleteVolumeGroupInstance() throws IOException {
1588 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1589 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1590 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1592 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1593 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1594 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1596 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1597 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1598 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1599 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1601 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1602 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1603 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1604 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1606 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1607 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1608 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1609 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1610 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1613 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1614 RequestReferences requestReferences = new RequestReferences();
1615 requestReferences.setInstanceId("1882939");
1616 expectedResponse.setRequestReferences(requestReferences);
1617 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1618 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
1620 ObjectMapper mapper = new ObjectMapper();
1621 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1623 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1624 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1625 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1628 public void createNetworkInstance() throws IOException {
1629 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1630 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1631 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1633 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1634 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1635 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1636 .withStatus(HttpStatus.SC_OK)));
1638 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1639 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1640 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1641 .withStatus(HttpStatus.SC_OK)));
1643 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1644 "modelName=GR-API-DEFAULT&action=createInstance"))
1645 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1646 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1647 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1649 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
1650 HttpHeaders headers = new HttpHeaders();
1651 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1653 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1654 RequestReferences requestReferences = new RequestReferences();
1655 requestReferences.setInstanceId("1882939");
1656 expectedResponse.setRequestReferences(requestReferences);
1657 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1658 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1660 ObjectMapper mapper = new ObjectMapper();
1661 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1663 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1664 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1665 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1668 public void updateNetworkInstance() throws IOException {
1669 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1670 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1671 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1673 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1674 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1675 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1676 .withStatus(HttpStatus.SC_OK)));
1678 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1679 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1680 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1681 .withStatus(HttpStatus.SC_OK)));
1683 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1684 "modelName=GR-API-DEFAULT&action=updateInstance"))
1685 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1686 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1687 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1689 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1690 RequestReferences requestReferences = new RequestReferences();
1691 requestReferences.setInstanceId("1882939");
1692 expectedResponse.setRequestReferences(requestReferences);
1693 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1694 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
1696 ObjectMapper mapper = new ObjectMapper();
1697 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1699 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1700 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1701 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1702 assertTrue(response.getBody().contains("1882939"));
1705 public void deleteNetworkInstance() throws IOException {
1706 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1707 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1708 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1710 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1711 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1712 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1713 .withStatus(HttpStatus.SC_OK)));
1715 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1717 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1718 .withStatus(HttpStatus.SC_OK)));
1720 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1721 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1722 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1723 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1724 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1727 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1728 RequestReferences requestReferences = new RequestReferences();
1729 requestReferences.setInstanceId("1882939");
1730 expectedResponse.setRequestReferences(requestReferences);
1731 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1732 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
1734 ObjectMapper mapper = new ObjectMapper();
1735 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1737 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1738 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1739 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1742 public void deleteNetworkInstanceNoReqParams() throws IOException {
1743 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1744 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1745 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1747 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1748 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1749 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1750 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1751 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1755 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1756 RequestReferences requestReferences = new RequestReferences();
1757 requestReferences.setInstanceId("1882939");
1758 expectedResponse.setRequestReferences(requestReferences);
1759 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1760 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
1762 ObjectMapper mapper = new ObjectMapper();
1763 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1765 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1766 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1767 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1770 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1771 HttpHeaders headers = new HttpHeaders();
1772 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1774 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1775 expectedRecord.setRequestStatus("FAILED");
1776 expectedRecord.setStatusMessage("Error mapping request: ");
1777 expectedRecord.setProgress(100L);
1778 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1779 expectedRecord.setLastModifiedBy("APIH");
1780 expectedRecord.setRequestScope("network");
1781 expectedRecord.setRequestAction("deleteInstance");
1782 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1784 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1785 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1789 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1792 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1793 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1794 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1796 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1800 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1801 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1802 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1803 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1805 ServiceRecipe serviceRecipe = new ServiceRecipe();
1806 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1807 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1808 serviceRecipe.setAction(Action.createInstance.toString());
1809 serviceRecipe.setId(1);
1810 serviceRecipe.setRecipeTimeout(180);
1811 Service defaultService = new Service();
1812 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1814 stubFor(get(urlMatching(".*/service/.*"))
1815 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1816 .withBody(mapper.writeValueAsString(defaultService))
1817 .withStatus(HttpStatus.SC_OK)));
1819 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1820 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1821 .withBody(mapper.writeValueAsString(serviceRecipe))
1822 .withStatus(HttpStatus.SC_OK)));
1824 uri = servInstanceuri + "v7" + "/serviceInstances";
1825 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
1828 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1829 RequestReferences requestReferences = new RequestReferences();
1830 requestReferences.setInstanceId("1882939");
1831 expectedResponse.setRequestReferences(requestReferences);
1833 ObjectMapper mapper = new ObjectMapper();
1834 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1836 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1837 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1838 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1842 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1843 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1844 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1845 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1847 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1848 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1849 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1850 .withStatus(HttpStatus.SC_OK)));
1852 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1853 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1854 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1855 .withStatus(HttpStatus.SC_OK)));
1857 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1858 "modelName=GR-API-DEFAULT&action=createInstance"))
1859 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1860 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1861 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1863 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1864 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
1867 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1868 RequestReferences requestReferences = new RequestReferences();
1869 requestReferences.setInstanceId("1882939");
1870 expectedResponse.setRequestReferences(requestReferences);
1872 ObjectMapper mapper = new ObjectMapper();
1873 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1875 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1876 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1877 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1881 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1882 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1883 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1884 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1886 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1887 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1890 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1891 RequestReferences requestReferences = new RequestReferences();
1892 requestReferences.setInstanceId("1882939");
1893 expectedResponse.setRequestReferences(requestReferences);
1895 ObjectMapper mapper = new ObjectMapper();
1896 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1898 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1902 public void createNetworkInstanceTestApiGrApi() throws IOException {
1903 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1904 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1905 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1907 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1908 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1909 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1910 .withStatus(HttpStatus.SC_OK)));
1912 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1913 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1914 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1915 .withStatus(HttpStatus.SC_OK)));
1917 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1918 "modelName=GR-API-DEFAULT&action=createInstance"))
1919 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1920 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1921 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1923 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1924 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
1927 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1928 RequestReferences requestReferences = new RequestReferences();
1929 requestReferences.setInstanceId("1882939");
1930 expectedResponse.setRequestReferences(requestReferences);
1932 ObjectMapper mapper = new ObjectMapper();
1933 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1935 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1936 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1937 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1941 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1942 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1943 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1944 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1946 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1947 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1948 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1949 .withStatus(HttpStatus.SC_OK)));
1951 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1952 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1953 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1954 .withStatus(HttpStatus.SC_OK)));
1956 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1957 "modelName=VNF-API-DEFAULT&action=createInstance"))
1958 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1959 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1960 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1962 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1963 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
1966 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1967 RequestReferences requestReferences = new RequestReferences();
1968 requestReferences.setInstanceId("1882939");
1969 expectedResponse.setRequestReferences(requestReferences);
1971 ObjectMapper mapper = new ObjectMapper();
1972 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1974 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1975 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1976 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1980 public void activateServiceInstanceRequestStatus() throws IOException{
1981 ServiceRecipe serviceRecipe = new ServiceRecipe();
1982 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1983 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1984 serviceRecipe.setAction(Action.createInstance.toString());
1985 serviceRecipe.setId(1);
1986 serviceRecipe.setRecipeTimeout(180);
1987 Service defaultService = new Service();
1988 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1990 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1991 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1992 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1993 HttpHeaders headers = new HttpHeaders();
1994 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
1996 stubFor(get(urlMatching(".*/service/.*"))
1997 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1998 .withBody(mapper.writeValueAsString(defaultService))
1999 .withStatus(HttpStatus.SC_OK)));
2001 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2002 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2003 .withBody(mapper.writeValueAsString(serviceRecipe))
2004 .withStatus(HttpStatus.SC_OK)));
2007 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2008 RequestReferences requestReferences = new RequestReferences();
2009 requestReferences.setInstanceId("1882939");
2010 expectedResponse.setRequestReferences(requestReferences);
2011 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2012 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2014 ObjectMapper mapper = new ObjectMapper();
2015 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2017 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2018 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2019 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2023 public void invalidRequestId() throws IOException {
2024 String illegalRequestId = "1234";
2025 HttpHeaders headers = new HttpHeaders();
2026 headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2028 uri = servInstanceuri + "v5/serviceInstances";
2029 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2031 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2032 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2035 public void invalidBPELResponse() throws IOException{
2037 ServiceRecipe serviceRecipe = new ServiceRecipe();
2038 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2039 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2040 serviceRecipe.setAction(Action.createInstance.toString());
2041 serviceRecipe.setId(1);
2042 serviceRecipe.setRecipeTimeout(180);
2043 Service defaultService = new Service();
2044 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2046 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2048 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2050 stubFor(get(urlMatching(".*/service/.*"))
2051 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2052 .withBody(mapper.writeValueAsString(defaultService))
2053 .withStatus(HttpStatus.SC_OK)));
2055 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2056 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2057 .withBody(mapper.writeValueAsString(serviceRecipe))
2058 .withStatus(HttpStatus.SC_OK)));
2060 uri = servInstanceuri + "v5/serviceInstances";
2061 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2063 ObjectMapper mapper = new ObjectMapper();
2064 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2065 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2067 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2068 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2069 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
2072 public void unauthorizedBPELResponse() throws IOException{
2074 ServiceRecipe serviceRecipe = new ServiceRecipe();
2075 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2076 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2077 serviceRecipe.setAction(Action.createInstance.toString());
2078 serviceRecipe.setId(1);
2079 serviceRecipe.setRecipeTimeout(180);
2080 Service defaultService = new Service();
2081 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2083 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2084 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2085 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2087 stubFor(get(urlMatching(".*/service/.*"))
2088 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2089 .withBody(mapper.writeValueAsString(defaultService))
2090 .withStatus(HttpStatus.SC_OK)));
2092 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2093 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2094 .withBody(mapper.writeValueAsString(serviceRecipe))
2095 .withStatus(HttpStatus.SC_OK)));
2097 uri = servInstanceuri + "v5/serviceInstances";
2098 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2100 ObjectMapper mapper = new ObjectMapper();
2101 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2102 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2104 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2105 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2106 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2110 public void invalidBPELResponse2() throws IOException{
2112 ServiceRecipe serviceRecipe = new ServiceRecipe();
2113 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2114 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2115 serviceRecipe.setAction(Action.createInstance.toString());
2116 serviceRecipe.setId(1);
2117 serviceRecipe.setRecipeTimeout(180);
2118 Service defaultService = new Service();
2119 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2121 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2122 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2123 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2125 stubFor(get(urlMatching(".*/service/.*"))
2126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2127 .withBody(mapper.writeValueAsString(defaultService))
2128 .withStatus(HttpStatus.SC_OK)));
2130 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2131 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2132 .withBody(mapper.writeValueAsString(serviceRecipe))
2133 .withStatus(HttpStatus.SC_OK)));
2134 uri = servInstanceuri + "v5/serviceInstances";
2135 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2137 ObjectMapper mapper = new ObjectMapper();
2138 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2139 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2141 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2142 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2143 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2147 public void createMacroServiceInstance() throws IOException{
2148 ServiceRecipe serviceRecipe = new ServiceRecipe();
2149 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2150 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2151 serviceRecipe.setAction(Action.createInstance.toString());
2152 serviceRecipe.setId(1);
2153 serviceRecipe.setRecipeTimeout(180);
2154 Service defaultService = new Service();
2155 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2157 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2158 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2159 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2161 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2162 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2163 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2165 stubFor(get(urlMatching(".*/service/.*"))
2166 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2167 .withBody(mapper.writeValueAsString(defaultService))
2168 .withStatus(HttpStatus.SC_OK)));
2170 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2171 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2172 .withBody(mapper.writeValueAsString(serviceRecipe))
2173 .withStatus(HttpStatus.SC_OK)));
2176 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2177 RequestReferences requestReferences = new RequestReferences();
2178 requestReferences.setInstanceId("1882939");
2179 expectedResponse.setRequestReferences(requestReferences);
2180 uri = servInstanceUriPrev7 + "v5";
2181 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
2183 ObjectMapper mapper = new ObjectMapper();
2184 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2187 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2188 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2189 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2193 public void testUserParams() throws IOException {
2194 ObjectMapper mapper = new ObjectMapper();
2195 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2196 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2197 String userParamsTxt = inputStream("/userParams.txt");
2199 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2200 System.out.println(userParams);
2201 assertTrue(userParams.size() > 0);
2202 assertTrue(userParams.get(0).containsKey("name"));
2203 assertTrue(userParams.get(0).containsKey("value"));
2204 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2208 public void testConfigureCloudConfig() throws IOException {
2209 ObjectMapper mapper = new ObjectMapper();
2210 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2211 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2213 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2214 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2218 public void testMapToLegacyRequest() throws IOException {
2219 ObjectMapper mapper = new ObjectMapper();
2220 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2221 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2222 servInstances.mapToLegacyRequest(request.getRequestDetails());
2223 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2224 assertThat(request, sameBeanAs(expected));
2227 public void scaleOutVfModule() throws IOException {
2228 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2229 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2230 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2232 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2233 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2234 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2235 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2237 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2239 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2240 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2242 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2244 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2245 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2248 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2249 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2250 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2251 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2253 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2254 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2255 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2258 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2259 RequestReferences requestReferences = new RequestReferences();
2260 requestReferences.setInstanceId("1882939");
2261 expectedResponse.setRequestReferences(requestReferences);
2262 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2263 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST);
2265 ObjectMapper mapper = new ObjectMapper();
2266 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2268 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2269 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2270 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2271 assertTrue(response.getBody().contains("1882939"));
2274 public void createServiceInstanceBadResponse() throws IOException{
2275 ServiceRecipe serviceRecipe = new ServiceRecipe();
2276 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2277 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2278 serviceRecipe.setAction(Action.createInstance.toString());
2279 serviceRecipe.setId(1);
2280 serviceRecipe.setRecipeTimeout(180);
2281 Service defaultService = new Service();
2282 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2284 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2286 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2288 stubFor(get(urlMatching(".*/service/.*"))
2289 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2290 .withBody(mapper.writeValueAsString(defaultService))
2291 .withStatus(HttpStatus.SC_OK)));
2293 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2294 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2295 .withBody(mapper.writeValueAsString(serviceRecipe))
2296 .withStatus(HttpStatus.SC_OK)));
2298 uri = servInstanceuri + "v5/serviceInstances";
2299 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2301 ObjectMapper mapper = new ObjectMapper();
2302 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2303 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2305 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2306 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2307 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2310 public void createServiceInstanceDuplicateError() throws IOException{
2311 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2312 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2313 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2315 uri = servInstanceuri + "v5/serviceInstances";
2316 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2318 ObjectMapper mapper = new ObjectMapper();
2319 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2320 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2322 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2323 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2324 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2327 public void createServiceInstanceSaveError() throws IOException{
2328 ServiceRecipe serviceRecipe = new ServiceRecipe();
2329 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2330 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2331 serviceRecipe.setAction(Action.createInstance.toString());
2332 serviceRecipe.setId(1);
2333 serviceRecipe.setRecipeTimeout(180);
2334 Service defaultService = new Service();
2335 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2336 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2337 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2338 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2339 stubFor(get(urlMatching(".*/service/.*"))
2340 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2341 .withBody(mapper.writeValueAsString(defaultService))
2342 .withStatus(HttpStatus.SC_OK)));
2344 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2345 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2346 .withBody(mapper.writeValueAsString(serviceRecipe))
2347 .withStatus(HttpStatus.SC_OK)));
2349 uri = servInstanceuri + "v5/serviceInstances";
2350 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2352 ObjectMapper mapper = new ObjectMapper();
2353 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2354 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2356 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2357 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2358 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2361 public void createPortConfigurationSaveError() throws IOException {
2362 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2363 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2364 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2365 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2366 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2367 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2369 HttpHeaders headers = new HttpHeaders();
2371 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2372 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2374 ObjectMapper mapper = new ObjectMapper();
2375 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2376 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2378 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2379 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2380 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2383 public void createPortConfigDbUpdateError() throws IOException {
2384 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2385 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2386 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2388 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2389 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
2391 ObjectMapper mapper = new ObjectMapper();
2392 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2393 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2395 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2396 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2397 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2400 public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
2401 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2402 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2403 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2405 stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2406 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2407 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2408 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2410 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
2411 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2412 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2413 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2415 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
2416 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2417 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2418 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2419 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2420 HttpHeaders headers = new HttpHeaders();
2421 headers.set(MsoLogger.CLIENT_ID, "VID");
2423 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2424 RequestReferences requestReferences = new RequestReferences();
2425 requestReferences.setInstanceId("1882939");
2426 expectedResponse.setRequestReferences(requestReferences);
2427 uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2428 ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2430 ObjectMapper mapper = new ObjectMapper();
2431 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2434 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2435 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2436 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));