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;
38 import java.nio.file.Files;
39 import java.nio.file.Paths;
40 import java.util.List;
43 import javax.ws.rs.core.MediaType;
44 import javax.ws.rs.core.Response;
46 import org.apache.http.HttpStatus;
47 import org.junit.Before;
48 import org.junit.Test;
49 import org.onap.logging.ref.slf4j.ONAPLogConstants;
50 import org.onap.so.db.catalog.beans.Service;
51 import org.onap.so.db.catalog.beans.ServiceRecipe;
52 import org.onap.so.db.request.beans.InfraActiveRequests;
53 import org.onap.so.logger.MsoLogger;
54 import org.onap.so.serviceinstancebeans.CloudConfiguration;
55 import org.onap.so.serviceinstancebeans.ModelInfo;
56 import org.onap.so.serviceinstancebeans.RequestError;
57 import org.onap.so.serviceinstancebeans.RequestParameters;
58 import org.onap.so.serviceinstancebeans.RequestReferences;
59 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
60 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
61 import org.springframework.beans.factory.annotation.Autowired;
62 import org.springframework.beans.factory.annotation.Value;
63 import org.springframework.http.HttpEntity;
64 import org.springframework.http.HttpHeaders;
65 import org.springframework.http.HttpMethod;
66 import org.springframework.http.ResponseEntity;
67 import org.springframework.util.ResourceUtils;
68 import org.springframework.web.util.UriComponentsBuilder;
70 import com.fasterxml.jackson.annotation.JsonInclude.Include;
71 import com.fasterxml.jackson.databind.DeserializationFeature;
72 import com.fasterxml.jackson.databind.ObjectMapper;
73 import com.github.tomakehurst.wiremock.http.Fault;
75 import ch.qos.logback.classic.spi.ILoggingEvent;
78 public class ServiceInstancesTest extends BaseTest{
80 private final ObjectMapper mapper = new ObjectMapper();
83 private ServiceInstances servInstances;
85 @Value("${wiremock.server.port}")
86 private String wiremockPort;
88 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
89 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
93 public void beforeClass() {
94 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
95 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
96 .withStatus(HttpStatus.SC_OK)));
99 public String inputStream(String JsonInput)throws IOException{
100 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
101 return new String(Files.readAllBytes(Paths.get(JsonInput)));
104 private String getWiremockResponseForCatalogdb(String file) {
106 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
107 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
108 } catch (IOException e) {
115 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
117 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
118 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
120 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
121 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
124 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
126 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
128 return restTemplate.exchange(builder.toUriString(),
129 reqMethod, request, String.class);
132 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
133 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
137 public void test_mapJSONtoMSOStyle() throws IOException{
138 ObjectMapper mapper = new ObjectMapper();
139 mapper.setSerializationInclusion(Include.NON_NULL);
140 String testRequest= inputStream("/ServiceInstanceDefault.json");
141 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
142 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
143 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
144 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
145 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
146 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
147 assertEquals("10",modelInfo.getModelUuid());
151 public void createServiceInstanceVIDDefault() throws IOException{
152 TestAppender.events.clear();
154 ServiceRecipe serviceRecipe = new ServiceRecipe();
155 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
156 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
157 serviceRecipe.setAction(Action.createInstance.toString());
158 serviceRecipe.setId(1);
159 serviceRecipe.setRecipeTimeout(180);
160 Service defaultService = new Service();
161 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
164 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
165 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
166 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
168 stubFor(get(urlMatching(".*/service/search/.*"))
169 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
170 .withBody(mapper.writeValueAsString(defaultService))
171 .withStatus(HttpStatus.SC_OK)));
173 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
174 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
175 .withBody(mapper.writeValueAsString(serviceRecipe))
176 .withStatus(HttpStatus.SC_OK)));
177 HttpHeaders headers = new HttpHeaders();
178 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
179 headers.set(MsoLogger.CLIENT_ID, "VID");
181 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
182 RequestReferences requestReferences = new RequestReferences();
183 requestReferences.setInstanceId("1882939");
184 expectedResponse.setRequestReferences(requestReferences);
185 uri = servInstanceuri + "v5/serviceInstances";
186 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
188 ObjectMapper mapper = new ObjectMapper();
189 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
192 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
193 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
194 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
198 for(ILoggingEvent logEvent : TestAppender.events)
199 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
200 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
202 Map<String,String> mdc = logEvent.getMDCPropertyMap();
203 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
204 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
205 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
206 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
207 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
208 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
209 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
210 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
211 Map<String,String> mdc = logEvent.getMDCPropertyMap();
212 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
213 assertNotNull(mdc.get(MsoLogger.ENDTIME));
214 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
215 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
216 assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
217 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
218 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
219 assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
220 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
221 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
222 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
223 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
227 public void createServiceInstanceServiceInstancesUri() throws IOException{
228 ServiceRecipe serviceRecipe = new ServiceRecipe();
229 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
230 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
231 serviceRecipe.setAction(Action.createInstance.toString());
232 serviceRecipe.setId(1);
233 serviceRecipe.setRecipeTimeout(180);
234 Service defaultService = new Service();
235 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
237 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
239 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
242 stubFor(get(urlMatching(".*/service/search/.*"))
243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
244 .withBody(mapper.writeValueAsString(defaultService))
245 .withStatus(HttpStatus.SC_OK)));
247 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
248 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
249 .withBody(mapper.writeValueAsString(serviceRecipe))
250 .withStatus(HttpStatus.SC_OK)));
253 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
254 RequestReferences requestReferences = new RequestReferences();
255 requestReferences.setInstanceId("1882939");
256 expectedResponse.setRequestReferences(requestReferences);
257 uri = servInstanceUriPrev7 + "v5";
258 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
260 ObjectMapper mapper = new ObjectMapper();
261 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
264 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
265 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
266 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
269 public void createServiceInstanceBpelStatusError() throws IOException{
270 ServiceRecipe serviceRecipe = new ServiceRecipe();
271 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
272 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
273 serviceRecipe.setAction(Action.createInstance.toString());
274 serviceRecipe.setId(1);
275 serviceRecipe.setRecipeTimeout(180);
276 Service defaultService = new Service();
277 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
280 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
281 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
282 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
285 stubFor(get(urlMatching(".*/service/search/.*"))
286 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
287 .withBody(mapper.writeValueAsString(defaultService))
288 .withStatus(HttpStatus.SC_OK)));
290 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
291 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
292 .withBody(mapper.writeValueAsString(serviceRecipe))
293 .withStatus(HttpStatus.SC_OK)));
295 uri = servInstanceuri + "v5/serviceInstances";
296 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
298 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
301 public void createServiceInstanceBadGateway() throws IOException{
302 ServiceRecipe serviceRecipe = new ServiceRecipe();
303 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
304 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
305 serviceRecipe.setAction(Action.createInstance.toString());
306 serviceRecipe.setId(1);
307 serviceRecipe.setRecipeTimeout(180);
308 Service defaultService = new Service();
309 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
311 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
312 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
314 stubFor(get(urlMatching(".*/service/search/.*"))
315 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
316 .withBody(mapper.writeValueAsString(defaultService))
317 .withStatus(HttpStatus.SC_OK)));
319 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
321 .withBody(mapper.writeValueAsString(serviceRecipe))
322 .withStatus(HttpStatus.SC_OK)));
324 uri = servInstanceuri + "v5/serviceInstances";
325 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
327 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
330 public void createServiceInstanceEmptyResponse() throws IOException{
331 ServiceRecipe serviceRecipe = new ServiceRecipe();
332 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
333 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
334 serviceRecipe.setAction(Action.createInstance.toString());
335 serviceRecipe.setId(1);
336 serviceRecipe.setRecipeTimeout(180);
337 Service defaultService = new Service();
338 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
340 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
341 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
343 stubFor(get(urlMatching(".*/service/search/.*"))
344 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
345 .withBody(mapper.writeValueAsString(defaultService))
346 .withStatus(HttpStatus.SC_OK)));
348 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
349 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
350 .withBody(mapper.writeValueAsString(serviceRecipe))
351 .withStatus(HttpStatus.SC_OK)));
353 uri = servInstanceuri + "v5/serviceInstances";
354 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
356 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
359 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
360 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
361 HttpHeaders headers = new HttpHeaders();
362 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
363 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, headers);
365 Service defaultService = new Service();
366 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
368 stubFor(get(urlMatching(".*/service/search/.*"))
369 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
370 .withBody(mapper.writeValueAsString(defaultService))
371 .withStatus(HttpStatus.SC_OK)));
374 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
375 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
376 .withStatus(HttpStatus.SC_NOT_FOUND)));
378 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
381 public void activateServiceInstanceNoRecipe() throws IOException{
382 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
383 Service defaultService = new Service();
384 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
385 stubFor(get(urlMatching(".*/service/search/.*"))
386 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
387 .withBody(mapper.writeValueAsString(defaultService))
388 .withStatus(HttpStatus.SC_OK)));
390 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
391 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
392 .withStatus(HttpStatus.SC_NOT_FOUND)));
394 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
396 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
399 public void activateServiceInstance() throws IOException{
400 ServiceRecipe serviceRecipe = new ServiceRecipe();
401 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
402 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
403 serviceRecipe.setAction(Action.createInstance.toString());
404 serviceRecipe.setId(1);
405 serviceRecipe.setRecipeTimeout(180);
406 Service defaultService = new Service();
407 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
409 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
410 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
411 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
413 stubFor(get(urlMatching(".*/service/search/.*"))
414 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
415 .withBody(mapper.writeValueAsString(defaultService))
416 .withStatus(HttpStatus.SC_OK)));
418 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
419 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
420 .withBody(mapper.writeValueAsString(serviceRecipe))
421 .withStatus(HttpStatus.SC_OK)));
422 HttpHeaders headers = new HttpHeaders();
423 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
425 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
426 RequestReferences requestReferences = new RequestReferences();
427 requestReferences.setInstanceId("1882939");
428 expectedResponse.setRequestReferences(requestReferences);
429 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
430 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
432 ObjectMapper mapper = new ObjectMapper();
433 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
435 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
436 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
437 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
440 public void deactivateServiceInstance() throws IOException{
442 ServiceRecipe serviceRecipe = new ServiceRecipe();
443 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
444 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
445 serviceRecipe.setAction(Action.createInstance.toString());
446 serviceRecipe.setId(1);
447 serviceRecipe.setRecipeTimeout(180);
448 Service defaultService = new Service();
449 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
451 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
452 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
453 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
455 stubFor(get(urlMatching(".*/service/.*"))
456 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
457 .withBody(mapper.writeValueAsString(defaultService))
458 .withStatus(HttpStatus.SC_OK)));
460 stubFor(get(urlMatching(".*/service/search/.*"))
461 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
462 .withBody(mapper.writeValueAsString(defaultService))
463 .withStatus(HttpStatus.SC_OK)));
465 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
466 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
467 .withBody(mapper.writeValueAsString(serviceRecipe))
468 .withStatus(HttpStatus.SC_OK)));
471 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
472 RequestReferences requestReferences = new RequestReferences();
473 requestReferences.setInstanceId("1882939");
474 expectedResponse.setRequestReferences(requestReferences);
475 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
476 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
478 ObjectMapper mapper = new ObjectMapper();
479 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
481 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
482 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
483 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
486 public void deleteServiceInstance() throws IOException {
487 ServiceRecipe serviceRecipe = new ServiceRecipe();
488 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
489 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
490 serviceRecipe.setAction(Action.createInstance.toString());
491 serviceRecipe.setId(1);
492 serviceRecipe.setRecipeTimeout(180);
493 Service defaultService = new Service();
494 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
496 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
497 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
498 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
500 stubFor(get(urlMatching(".*/service/.*"))
501 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
502 .withBody(mapper.writeValueAsString(defaultService))
503 .withStatus(HttpStatus.SC_OK)));
505 stubFor(get(urlMatching(".*/service/search/.*"))
506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
507 .withBody(mapper.writeValueAsString(defaultService))
508 .withStatus(HttpStatus.SC_OK)));
510 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
511 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
512 .withBody(mapper.writeValueAsString(serviceRecipe))
513 .withStatus(HttpStatus.SC_OK)));
515 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
516 RequestReferences requestReferences = new RequestReferences();
517 requestReferences.setInstanceId("1882939");
518 expectedResponse.setRequestReferences(requestReferences);
519 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
520 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
522 ObjectMapper mapper = new ObjectMapper();
523 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
525 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
526 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
527 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
530 public void assignServiceInstance() throws IOException {
531 ServiceRecipe serviceRecipe = new ServiceRecipe();
532 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
533 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
534 serviceRecipe.setAction(Action.createInstance.toString());
535 serviceRecipe.setId(1);
536 serviceRecipe.setRecipeTimeout(180);
537 Service defaultService = new Service();
538 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
540 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
541 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
542 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
544 stubFor(get(urlMatching(".*/service/.*"))
545 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
546 .withBody(mapper.writeValueAsString(defaultService))
547 .withStatus(HttpStatus.SC_OK)));
549 stubFor(get(urlMatching(".*/service/search/.*"))
550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
551 .withBody(mapper.writeValueAsString(defaultService))
552 .withStatus(HttpStatus.SC_OK)));
554 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
555 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
556 .withBody(mapper.writeValueAsString(serviceRecipe))
557 .withStatus(HttpStatus.SC_OK)));
559 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
560 RequestReferences requestReferences = new RequestReferences();
561 requestReferences.setInstanceId("1882939");
562 expectedResponse.setRequestReferences(requestReferences);
563 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
564 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
566 ObjectMapper mapper = new ObjectMapper();
567 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
569 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
570 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
571 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
575 public void unassignServiceInstance() throws IOException {
576 ServiceRecipe serviceRecipe = new ServiceRecipe();
577 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
578 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
579 serviceRecipe.setAction(Action.createInstance.toString());
580 serviceRecipe.setId(1);
581 serviceRecipe.setRecipeTimeout(180);
582 Service defaultService = new Service();
583 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
585 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
586 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
587 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
589 stubFor(get(urlMatching(".*/service/.*"))
590 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
591 .withBody(mapper.writeValueAsString(defaultService))
592 .withStatus(HttpStatus.SC_OK)));
594 stubFor(get(urlMatching(".*/service/search/.*"))
595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
596 .withBody(mapper.writeValueAsString(defaultService))
597 .withStatus(HttpStatus.SC_OK)));
599 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
601 .withBody(mapper.writeValueAsString(serviceRecipe))
602 .withStatus(HttpStatus.SC_OK)));
604 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
605 RequestReferences requestReferences = new RequestReferences();
606 requestReferences.setInstanceId("1882939");
607 expectedResponse.setRequestReferences(requestReferences);
608 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
609 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
611 ObjectMapper mapper = new ObjectMapper();
612 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
614 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
615 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
616 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
619 public void createPortConfiguration() throws IOException {
620 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
621 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
622 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
623 HttpHeaders headers = new HttpHeaders();
624 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
626 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
627 RequestReferences requestReferences = new RequestReferences();
628 requestReferences.setInstanceId("1882939");
629 expectedResponse.setRequestReferences(requestReferences);
630 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
631 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
633 ObjectMapper mapper = new ObjectMapper();
634 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
636 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
637 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
638 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
639 assertTrue(response.getBody().contains("1882939"));
642 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
643 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
644 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
646 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
649 public void deletePortConfiguration() throws IOException {
650 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
651 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
652 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
654 HttpHeaders headers = new HttpHeaders();
655 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
657 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
658 RequestReferences requestReferences = new RequestReferences();
659 requestReferences.setInstanceId("1882939");
660 expectedResponse.setRequestReferences(requestReferences);
661 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
662 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
664 ObjectMapper mapper = new ObjectMapper();
665 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
667 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
668 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
669 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
672 public void enablePort() throws IOException {
673 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
674 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
675 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
677 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
678 RequestReferences requestReferences = new RequestReferences();
679 requestReferences.setInstanceId("1882939");
680 expectedResponse.setRequestReferences(requestReferences);
681 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
682 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
684 ObjectMapper mapper = new ObjectMapper();
685 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
687 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
688 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
689 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
692 public void disablePort() throws IOException {
693 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
694 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
695 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
697 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
698 RequestReferences requestReferences = new RequestReferences();
699 requestReferences.setInstanceId("1882939");
700 expectedResponse.setRequestReferences(requestReferences);
701 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
702 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
704 ObjectMapper mapper = new ObjectMapper();
705 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
707 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
708 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
709 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
712 public void activatePort() throws IOException {
713 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
714 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
715 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
717 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
718 RequestReferences requestReferences = new RequestReferences();
719 requestReferences.setInstanceId("1882939");
720 expectedResponse.setRequestReferences(requestReferences);
721 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
722 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
724 ObjectMapper mapper = new ObjectMapper();
725 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
727 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
728 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
729 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
732 public void deactivatePort() throws IOException {
733 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
734 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
735 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
737 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
738 RequestReferences requestReferences = new RequestReferences();
739 requestReferences.setInstanceId("1882939");
740 expectedResponse.setRequestReferences(requestReferences);
741 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
742 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
744 ObjectMapper mapper = new ObjectMapper();
745 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
747 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
748 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
749 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
752 public void addRelationships() throws IOException {
753 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
754 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
755 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
758 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
759 RequestReferences requestReferences = new RequestReferences();
760 requestReferences.setInstanceId("1882939");
761 expectedResponse.setRequestReferences(requestReferences);
762 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
763 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
765 ObjectMapper mapper = new ObjectMapper();
766 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
768 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
769 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
770 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
773 public void removeRelationships() throws IOException {
774 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
775 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
776 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
779 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
780 RequestReferences requestReferences = new RequestReferences();
781 requestReferences.setInstanceId("1882939");
782 expectedResponse.setRequestReferences(requestReferences);
783 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
784 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
786 ObjectMapper mapper = new ObjectMapper();
787 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
789 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
790 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
791 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
794 public void createVnfInstanceNoALaCarte() throws IOException {
795 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
796 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
797 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
800 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
801 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
802 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
803 .withStatus(org.apache.http.HttpStatus.SC_OK)));
805 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
806 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
807 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
808 .withStatus(org.apache.http.HttpStatus.SC_OK)));
810 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
812 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
813 .withStatus(org.apache.http.HttpStatus.SC_OK)));
816 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
817 RequestReferences requestReferences = new RequestReferences();
818 requestReferences.setInstanceId("1882939");
819 expectedResponse.setRequestReferences(requestReferences);
820 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
821 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
823 ObjectMapper mapper = new ObjectMapper();
824 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
826 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
827 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
828 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
831 public void createVnfInstance() throws IOException {
832 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
833 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
834 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
836 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
837 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
838 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
839 .withStatus(org.apache.http.HttpStatus.SC_OK)));
840 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
841 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
842 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
843 .withStatus(org.apache.http.HttpStatus.SC_OK)));
846 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
847 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
848 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
849 .withStatus(org.apache.http.HttpStatus.SC_OK)));
851 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
852 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
853 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
854 .withStatus(org.apache.http.HttpStatus.SC_OK)));
856 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
857 HttpHeaders headers = new HttpHeaders();
858 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
860 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
861 RequestReferences requestReferences = new RequestReferences();
862 requestReferences.setInstanceId("1882939");
863 expectedResponse.setRequestReferences(requestReferences);
864 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
865 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
867 ObjectMapper mapper = new ObjectMapper();
868 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
870 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
871 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
872 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
873 assertTrue(response.getBody().contains("1882939"));
876 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
877 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
878 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
880 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
883 public void createVnfInstanceInvalidVnfResource() throws IOException {
884 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
885 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
887 ObjectMapper mapper = new ObjectMapper();
888 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
889 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
891 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
892 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
893 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
896 public void replaceVnfInstance() throws IOException {
897 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
898 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
899 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
901 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
902 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
903 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
904 .withStatus(org.apache.http.HttpStatus.SC_OK)));
906 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
907 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
908 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
909 .withStatus(org.apache.http.HttpStatus.SC_OK)));
911 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
912 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
913 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
914 .withStatus(org.apache.http.HttpStatus.SC_OK)));
916 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
917 RequestReferences requestReferences = new RequestReferences();
918 requestReferences.setInstanceId("1882939");
919 expectedResponse.setRequestReferences(requestReferences);
920 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
921 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
923 ObjectMapper mapper = new ObjectMapper();
924 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
926 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
927 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
928 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
931 public void replaceVnfRecreateInstance() throws IOException {
932 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
933 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
934 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
936 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
937 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
938 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
939 .withStatus(org.apache.http.HttpStatus.SC_OK)));
941 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
942 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
943 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
944 .withStatus(org.apache.http.HttpStatus.SC_OK)));
946 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
947 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
948 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
949 .withStatus(org.apache.http.HttpStatus.SC_OK)));
952 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
953 RequestReferences requestReferences = new RequestReferences();
954 requestReferences.setInstanceId("1882939");
955 expectedResponse.setRequestReferences(requestReferences);
956 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
957 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
958 logger.debug(response.getBody());
959 ObjectMapper mapper = new ObjectMapper();
960 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
962 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
963 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
964 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
967 public void recreateVnfInstance() throws IOException {
968 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
969 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
970 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
972 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
973 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
974 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
975 .withStatus(org.apache.http.HttpStatus.SC_OK)));
977 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
978 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
979 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
980 .withStatus(org.apache.http.HttpStatus.SC_OK)));
982 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
983 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
984 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
985 .withStatus(org.apache.http.HttpStatus.SC_OK)));
988 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
989 RequestReferences requestReferences = new RequestReferences();
990 requestReferences.setInstanceId("1882939");
991 expectedResponse.setRequestReferences(requestReferences);
992 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
993 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST);
994 logger.debug(response.getBody());
995 ObjectMapper mapper = new ObjectMapper();
996 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
998 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
999 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1000 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1003 public void updateVnfInstance() throws IOException {
1004 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1005 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1006 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1008 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
1009 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1010 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1011 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1013 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
1014 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1015 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1016 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1018 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1019 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1020 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1021 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1022 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1025 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1026 RequestReferences requestReferences = new RequestReferences();
1027 requestReferences.setInstanceId("1882939");
1028 expectedResponse.setRequestReferences(requestReferences);
1029 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1030 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
1032 ObjectMapper mapper = new ObjectMapper();
1033 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1035 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1036 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1037 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1040 public void applyUpdatedConfig() throws IOException {
1041 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1042 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1043 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1046 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1047 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1048 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1049 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1050 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1052 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
1053 HttpHeaders headers = new HttpHeaders();
1054 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1056 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1057 RequestReferences requestReferences = new RequestReferences();
1058 requestReferences.setInstanceId("1882939");
1059 expectedResponse.setRequestReferences(requestReferences);
1060 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1061 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1063 ObjectMapper mapper = new ObjectMapper();
1064 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1066 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1067 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1068 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1071 public void deleteVnfInstanceV5() throws IOException {
1072 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1073 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1074 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1076 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1077 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1078 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1079 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1080 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1082 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1083 RequestReferences requestReferences = new RequestReferences();
1084 requestReferences.setInstanceId("1882939");
1085 expectedResponse.setRequestReferences(requestReferences);
1086 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1087 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
1089 ObjectMapper mapper = new ObjectMapper();
1090 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1092 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1093 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1094 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1097 public void createVfModuleInstance() throws IOException {
1099 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1100 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1101 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1102 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1104 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1105 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1106 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1107 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1109 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1110 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1111 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1112 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1114 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1115 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1116 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1118 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1119 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1120 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1121 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1122 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1124 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1125 RequestReferences requestReferences = new RequestReferences();
1126 requestReferences.setInstanceId("1882939");
1127 expectedResponse.setRequestReferences(requestReferences);
1128 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1129 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
1131 ObjectMapper mapper = new ObjectMapper();
1132 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1134 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1135 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1136 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1137 assertTrue(response.getBody().contains("1882939"));
1140 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1141 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1142 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1143 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1145 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1146 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1147 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1148 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1150 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1151 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1152 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1153 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1154 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1156 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1157 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1158 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1159 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1161 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1162 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1163 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1164 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1165 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1167 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1168 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1169 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1170 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1172 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1173 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1174 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1175 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1178 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1179 "[?]vnfComponentType=vfModule&action=createInstance"))
1180 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1181 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1182 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1185 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1186 RequestReferences requestReferences = new RequestReferences();
1187 requestReferences.setInstanceId("1882939");
1188 expectedResponse.setRequestReferences(requestReferences);
1189 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1190 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
1191 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1192 ObjectMapper mapper = new ObjectMapper();
1193 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1194 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1197 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1198 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1199 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1200 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1202 stubFor(get(urlMatching(".*/vnfResource/.*"))
1203 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1204 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1205 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1207 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1208 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1209 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1210 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1212 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1213 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1214 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1215 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1217 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1218 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1219 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1220 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1222 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1223 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1224 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1225 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1227 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1228 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1229 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1230 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1232 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1233 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1234 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1235 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1236 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1239 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1240 RequestReferences requestReferences = new RequestReferences();
1241 requestReferences.setInstanceId("1882939");
1242 expectedResponse.setRequestReferences(requestReferences);
1243 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1244 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
1246 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1247 ObjectMapper mapper = new ObjectMapper();
1248 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1249 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1252 public void createVfModuleInstanceNoRecipe() throws IOException {
1254 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1255 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1256 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1257 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1259 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1260 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1261 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1262 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1263 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1265 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1266 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1267 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1268 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1270 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1271 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1272 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1273 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1274 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1276 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1277 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
1279 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1280 ObjectMapper mapper = new ObjectMapper();
1281 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1282 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1283 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1286 public void replaceVfModuleInstance() throws IOException {
1287 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1288 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1289 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1291 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1292 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1293 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1294 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1295 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1297 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1298 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1299 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1300 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1301 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1303 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1304 RequestReferences requestReferences = new RequestReferences();
1305 requestReferences.setInstanceId("1882939");
1306 expectedResponse.setRequestReferences(requestReferences);
1307 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1308 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
1310 ObjectMapper mapper = new ObjectMapper();
1311 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1313 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1314 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1315 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1318 public void updateVfModuleInstance() throws IOException {
1319 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1321 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1323 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1324 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1325 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1326 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1328 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1329 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1330 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1331 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1333 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1335 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1336 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1338 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1339 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1340 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1341 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1342 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1345 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1346 RequestReferences requestReferences = new RequestReferences();
1347 requestReferences.setInstanceId("1882939");
1348 expectedResponse.setRequestReferences(requestReferences);
1349 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1350 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
1351 logger.debug(response.getBody());
1353 ObjectMapper mapper = new ObjectMapper();
1354 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1356 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1357 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1358 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1361 public void createVfModuleNoModelType() throws IOException{
1362 HttpHeaders headers = new HttpHeaders();
1363 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1364 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1365 expectedRecord.setRequestStatus("FAILED");
1366 expectedRecord.setAction("createInstance");
1367 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1368 expectedRecord.setProgress(100L);
1369 expectedRecord.setSource("VID");
1370 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1371 expectedRecord.setLastModifiedBy("APIH");
1372 expectedRecord.setVfModuleName("testVfModule2");
1373 expectedRecord.setVfModuleModelName("serviceModel");
1374 expectedRecord.setRequestScope("vfModule");
1375 expectedRecord.setRequestAction("createInstance");
1376 expectedRecord.setRequestorId("zz9999");
1377 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1378 //VnfType is not sent in this request, should be blank in db
1379 expectedRecord.setVnfType("");
1380 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1382 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1384 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1387 public void inPlaceSoftwareUpdate() throws IOException {
1388 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1389 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1390 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1392 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1393 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1394 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1395 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1396 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1399 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1400 RequestReferences requestReferences = new RequestReferences();
1401 requestReferences.setInstanceId("1882939");
1402 expectedResponse.setRequestReferences(requestReferences);
1403 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1404 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
1406 ObjectMapper mapper = new ObjectMapper();
1407 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1409 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1410 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1411 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1415 public void deleteVfModuleInstance() throws IOException {
1416 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1417 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1418 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1420 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1421 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1422 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1423 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1424 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1426 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1427 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1428 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1429 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1430 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1433 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1434 RequestReferences requestReferences = new RequestReferences();
1435 requestReferences.setInstanceId("1882939");
1436 expectedResponse.setRequestReferences(requestReferences);
1437 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1438 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
1440 ObjectMapper mapper = new ObjectMapper();
1441 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1443 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1444 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1445 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1448 public void deleteVfModuleNoModelInvariantId() throws IOException {
1449 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1450 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1451 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1453 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1454 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1455 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1456 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1457 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1460 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1461 RequestReferences requestReferences = new RequestReferences();
1462 requestReferences.setInstanceId("1882939");
1463 expectedResponse.setRequestReferences(requestReferences);
1464 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1465 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE);
1467 ObjectMapper mapper = new ObjectMapper();
1468 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1470 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1471 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1472 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1475 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1476 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1477 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1478 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1480 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1481 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1482 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1483 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1484 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1486 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1487 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1488 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1489 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1490 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1493 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1494 RequestReferences requestReferences = new RequestReferences();
1495 requestReferences.setInstanceId("1882939");
1496 expectedResponse.setRequestReferences(requestReferences);
1497 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1498 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
1500 ObjectMapper mapper = new ObjectMapper();
1501 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1503 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1504 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1505 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1508 public void createVolumeGroupInstance() throws IOException {
1509 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1510 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1511 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1513 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1514 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1515 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1516 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1518 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1519 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1520 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1521 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1523 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1524 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1525 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1526 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1527 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1530 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1531 RequestReferences requestReferences = new RequestReferences();
1532 requestReferences.setInstanceId("1882939");
1533 expectedResponse.setRequestReferences(requestReferences);
1534 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1535 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
1537 ObjectMapper mapper = new ObjectMapper();
1538 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1540 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1541 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1542 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1543 assertTrue(response.getBody().contains("1882939"));
1546 public void updateVolumeGroupInstance() throws IOException {
1547 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1548 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1549 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1551 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1552 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1553 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1554 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1556 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1557 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1558 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1559 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1561 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1562 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1563 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1564 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1565 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1568 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1569 RequestReferences requestReferences = new RequestReferences();
1570 requestReferences.setInstanceId("1882939");
1571 expectedResponse.setRequestReferences(requestReferences);
1572 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1573 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
1575 ObjectMapper mapper = new ObjectMapper();
1576 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1578 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1579 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1580 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1583 public void deleteVolumeGroupInstance() throws IOException {
1584 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1585 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1586 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
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(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1593 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1594 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1595 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1597 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1598 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1599 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1600 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1602 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1603 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1604 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1605 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1606 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1609 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1610 RequestReferences requestReferences = new RequestReferences();
1611 requestReferences.setInstanceId("1882939");
1612 expectedResponse.setRequestReferences(requestReferences);
1613 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1614 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
1616 ObjectMapper mapper = new ObjectMapper();
1617 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1619 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1620 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1621 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1624 public void createNetworkInstance() throws IOException {
1625 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1626 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1627 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1629 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1630 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1631 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1632 .withStatus(HttpStatus.SC_OK)));
1634 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1635 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1636 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1637 .withStatus(HttpStatus.SC_OK)));
1639 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1640 "modelName=GR-API-DEFAULT&action=createInstance"))
1641 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1642 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1643 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1645 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
1646 HttpHeaders headers = new HttpHeaders();
1647 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1649 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1650 RequestReferences requestReferences = new RequestReferences();
1651 requestReferences.setInstanceId("1882939");
1652 expectedResponse.setRequestReferences(requestReferences);
1653 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1654 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1656 ObjectMapper mapper = new ObjectMapper();
1657 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1659 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1660 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1661 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1664 public void updateNetworkInstance() throws IOException {
1665 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1666 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1667 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1669 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1670 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1671 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1672 .withStatus(HttpStatus.SC_OK)));
1674 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1675 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1676 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1677 .withStatus(HttpStatus.SC_OK)));
1679 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1680 "modelName=GR-API-DEFAULT&action=updateInstance"))
1681 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1682 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1683 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1685 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1686 RequestReferences requestReferences = new RequestReferences();
1687 requestReferences.setInstanceId("1882939");
1688 expectedResponse.setRequestReferences(requestReferences);
1689 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1690 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
1692 ObjectMapper mapper = new ObjectMapper();
1693 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1695 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1696 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1697 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1698 assertTrue(response.getBody().contains("1882939"));
1701 public void deleteNetworkInstance() throws IOException {
1702 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1703 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1704 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1706 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1707 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1708 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1709 .withStatus(HttpStatus.SC_OK)));
1711 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1712 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1713 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1714 .withStatus(HttpStatus.SC_OK)));
1716 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1717 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1718 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1719 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1720 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1723 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1724 RequestReferences requestReferences = new RequestReferences();
1725 requestReferences.setInstanceId("1882939");
1726 expectedResponse.setRequestReferences(requestReferences);
1727 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1728 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
1730 ObjectMapper mapper = new ObjectMapper();
1731 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1733 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1734 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1735 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1738 public void deleteNetworkInstanceNoReqParams() throws IOException {
1739 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1740 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1741 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1743 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1744 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1745 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1746 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1747 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1751 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1752 RequestReferences requestReferences = new RequestReferences();
1753 requestReferences.setInstanceId("1882939");
1754 expectedResponse.setRequestReferences(requestReferences);
1755 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1756 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
1758 ObjectMapper mapper = new ObjectMapper();
1759 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1761 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1762 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1763 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1766 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1767 HttpHeaders headers = new HttpHeaders();
1768 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1770 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1771 expectedRecord.setRequestStatus("FAILED");
1772 expectedRecord.setStatusMessage("Error mapping request: ");
1773 expectedRecord.setProgress(100L);
1774 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1775 expectedRecord.setLastModifiedBy("APIH");
1776 expectedRecord.setRequestScope("network");
1777 expectedRecord.setRequestAction("deleteInstance");
1778 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1780 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1781 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1785 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1788 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1789 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1790 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1792 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1796 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1797 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1798 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1799 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1801 ServiceRecipe serviceRecipe = new ServiceRecipe();
1802 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1803 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1804 serviceRecipe.setAction(Action.createInstance.toString());
1805 serviceRecipe.setId(1);
1806 serviceRecipe.setRecipeTimeout(180);
1807 Service defaultService = new Service();
1808 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1810 stubFor(get(urlMatching(".*/service/.*"))
1811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1812 .withBody(mapper.writeValueAsString(defaultService))
1813 .withStatus(HttpStatus.SC_OK)));
1815 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1816 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1817 .withBody(mapper.writeValueAsString(serviceRecipe))
1818 .withStatus(HttpStatus.SC_OK)));
1820 uri = servInstanceuri + "v7" + "/serviceInstances";
1821 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
1824 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1825 RequestReferences requestReferences = new RequestReferences();
1826 requestReferences.setInstanceId("1882939");
1827 expectedResponse.setRequestReferences(requestReferences);
1829 ObjectMapper mapper = new ObjectMapper();
1830 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1832 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1833 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1834 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1838 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1839 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1840 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1841 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1843 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1844 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1845 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1846 .withStatus(HttpStatus.SC_OK)));
1848 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1849 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1850 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1851 .withStatus(HttpStatus.SC_OK)));
1853 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1854 "modelName=GR-API-DEFAULT&action=createInstance"))
1855 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1856 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1857 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1859 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1860 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
1863 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1864 RequestReferences requestReferences = new RequestReferences();
1865 requestReferences.setInstanceId("1882939");
1866 expectedResponse.setRequestReferences(requestReferences);
1868 ObjectMapper mapper = new ObjectMapper();
1869 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1871 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1872 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1873 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1877 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1878 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1879 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1880 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1882 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1883 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1886 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1887 RequestReferences requestReferences = new RequestReferences();
1888 requestReferences.setInstanceId("1882939");
1889 expectedResponse.setRequestReferences(requestReferences);
1891 ObjectMapper mapper = new ObjectMapper();
1892 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1894 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1898 public void createNetworkInstanceTestApiGrApi() throws IOException {
1899 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1900 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1901 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1903 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1904 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1905 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1906 .withStatus(HttpStatus.SC_OK)));
1908 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1909 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1910 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1911 .withStatus(HttpStatus.SC_OK)));
1913 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1914 "modelName=GR-API-DEFAULT&action=createInstance"))
1915 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1916 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1917 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1919 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1920 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
1923 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1924 RequestReferences requestReferences = new RequestReferences();
1925 requestReferences.setInstanceId("1882939");
1926 expectedResponse.setRequestReferences(requestReferences);
1928 ObjectMapper mapper = new ObjectMapper();
1929 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1931 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1932 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1933 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1937 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1938 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1939 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1940 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1942 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1943 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1944 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1945 .withStatus(HttpStatus.SC_OK)));
1947 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1948 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1949 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1950 .withStatus(HttpStatus.SC_OK)));
1952 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1953 "modelName=VNF-API-DEFAULT&action=createInstance"))
1954 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1955 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1956 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1958 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1959 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
1962 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1963 RequestReferences requestReferences = new RequestReferences();
1964 requestReferences.setInstanceId("1882939");
1965 expectedResponse.setRequestReferences(requestReferences);
1967 ObjectMapper mapper = new ObjectMapper();
1968 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1970 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1971 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1972 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1976 public void activateServiceInstanceRequestStatus() throws IOException{
1977 ServiceRecipe serviceRecipe = new ServiceRecipe();
1978 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1979 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1980 serviceRecipe.setAction(Action.createInstance.toString());
1981 serviceRecipe.setId(1);
1982 serviceRecipe.setRecipeTimeout(180);
1983 Service defaultService = new Service();
1984 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1986 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1987 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1988 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1989 HttpHeaders headers = new HttpHeaders();
1990 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
1992 stubFor(get(urlMatching(".*/service/.*"))
1993 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1994 .withBody(mapper.writeValueAsString(defaultService))
1995 .withStatus(HttpStatus.SC_OK)));
1997 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1998 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1999 .withBody(mapper.writeValueAsString(serviceRecipe))
2000 .withStatus(HttpStatus.SC_OK)));
2003 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2004 RequestReferences requestReferences = new RequestReferences();
2005 requestReferences.setInstanceId("1882939");
2006 expectedResponse.setRequestReferences(requestReferences);
2007 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2008 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2010 ObjectMapper mapper = new ObjectMapper();
2011 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2013 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2014 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2015 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2019 public void invalidRequestId() throws IOException {
2020 String illegalRequestId = "1234";
2021 HttpHeaders headers = new HttpHeaders();
2022 headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2024 uri = servInstanceuri + "v5/serviceInstances";
2025 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2027 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2028 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2031 public void invalidBPELResponse() throws IOException{
2033 ServiceRecipe serviceRecipe = new ServiceRecipe();
2034 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2035 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2036 serviceRecipe.setAction(Action.createInstance.toString());
2037 serviceRecipe.setId(1);
2038 serviceRecipe.setRecipeTimeout(180);
2039 Service defaultService = new Service();
2040 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2042 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2043 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2044 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2046 stubFor(get(urlMatching(".*/service/.*"))
2047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2048 .withBody(mapper.writeValueAsString(defaultService))
2049 .withStatus(HttpStatus.SC_OK)));
2051 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2052 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2053 .withBody(mapper.writeValueAsString(serviceRecipe))
2054 .withStatus(HttpStatus.SC_OK)));
2056 uri = servInstanceuri + "v5/serviceInstances";
2057 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2059 ObjectMapper mapper = new ObjectMapper();
2060 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2061 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2063 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2064 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2065 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
2068 public void unauthorizedBPELResponse() throws IOException{
2070 ServiceRecipe serviceRecipe = new ServiceRecipe();
2071 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2072 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2073 serviceRecipe.setAction(Action.createInstance.toString());
2074 serviceRecipe.setId(1);
2075 serviceRecipe.setRecipeTimeout(180);
2076 Service defaultService = new Service();
2077 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2079 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2081 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2083 stubFor(get(urlMatching(".*/service/.*"))
2084 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2085 .withBody(mapper.writeValueAsString(defaultService))
2086 .withStatus(HttpStatus.SC_OK)));
2088 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2089 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2090 .withBody(mapper.writeValueAsString(serviceRecipe))
2091 .withStatus(HttpStatus.SC_OK)));
2093 uri = servInstanceuri + "v5/serviceInstances";
2094 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2096 ObjectMapper mapper = new ObjectMapper();
2097 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2098 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2100 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2101 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2102 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2106 public void invalidBPELResponse2() throws IOException{
2108 ServiceRecipe serviceRecipe = new ServiceRecipe();
2109 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2110 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2111 serviceRecipe.setAction(Action.createInstance.toString());
2112 serviceRecipe.setId(1);
2113 serviceRecipe.setRecipeTimeout(180);
2114 Service defaultService = new Service();
2115 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2117 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2118 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2119 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2121 stubFor(get(urlMatching(".*/service/.*"))
2122 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2123 .withBody(mapper.writeValueAsString(defaultService))
2124 .withStatus(HttpStatus.SC_OK)));
2126 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2127 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2128 .withBody(mapper.writeValueAsString(serviceRecipe))
2129 .withStatus(HttpStatus.SC_OK)));
2130 uri = servInstanceuri + "v5/serviceInstances";
2131 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2133 ObjectMapper mapper = new ObjectMapper();
2134 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2135 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2137 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2138 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2139 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2143 public void createMacroServiceInstance() throws IOException{
2144 ServiceRecipe serviceRecipe = new ServiceRecipe();
2145 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2146 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2147 serviceRecipe.setAction(Action.createInstance.toString());
2148 serviceRecipe.setId(1);
2149 serviceRecipe.setRecipeTimeout(180);
2150 Service defaultService = new Service();
2151 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2153 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2154 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2155 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2157 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2158 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2159 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2161 stubFor(get(urlMatching(".*/service/.*"))
2162 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2163 .withBody(mapper.writeValueAsString(defaultService))
2164 .withStatus(HttpStatus.SC_OK)));
2166 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2167 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2168 .withBody(mapper.writeValueAsString(serviceRecipe))
2169 .withStatus(HttpStatus.SC_OK)));
2172 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2173 RequestReferences requestReferences = new RequestReferences();
2174 requestReferences.setInstanceId("1882939");
2175 expectedResponse.setRequestReferences(requestReferences);
2176 uri = servInstanceUriPrev7 + "v5";
2177 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
2179 ObjectMapper mapper = new ObjectMapper();
2180 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2183 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2184 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2185 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2189 public void testUserParams() throws IOException {
2190 ObjectMapper mapper = new ObjectMapper();
2191 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2192 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2193 String userParamsTxt = inputStream("/userParams.txt");
2195 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2196 System.out.println(userParams);
2197 assertTrue(userParams.size() > 0);
2198 assertTrue(userParams.get(0).containsKey("name"));
2199 assertTrue(userParams.get(0).containsKey("value"));
2200 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2204 public void testConfigureCloudConfig() throws IOException {
2205 ObjectMapper mapper = new ObjectMapper();
2206 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2207 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2209 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2210 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2214 public void testMapToLegacyRequest() throws IOException {
2215 ObjectMapper mapper = new ObjectMapper();
2216 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2217 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2218 servInstances.mapToLegacyRequest(request.getRequestDetails());
2219 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2220 assertThat(request, sameBeanAs(expected));
2223 public void scaleOutVfModule() throws IOException {
2224 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2225 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2226 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2228 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2229 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2230 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2231 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2233 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2234 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2235 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2236 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2238 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2239 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2240 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2241 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2244 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2245 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2246 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2247 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2249 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2250 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2251 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2254 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2255 RequestReferences requestReferences = new RequestReferences();
2256 requestReferences.setInstanceId("1882939");
2257 expectedResponse.setRequestReferences(requestReferences);
2258 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2259 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST);
2261 ObjectMapper mapper = new ObjectMapper();
2262 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2264 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2265 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2266 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2267 assertTrue(response.getBody().contains("1882939"));
2270 public void createServiceInstanceBadResponse() throws IOException{
2271 ServiceRecipe serviceRecipe = new ServiceRecipe();
2272 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2273 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2274 serviceRecipe.setAction(Action.createInstance.toString());
2275 serviceRecipe.setId(1);
2276 serviceRecipe.setRecipeTimeout(180);
2277 Service defaultService = new Service();
2278 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2280 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2281 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2282 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2284 stubFor(get(urlMatching(".*/service/.*"))
2285 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2286 .withBody(mapper.writeValueAsString(defaultService))
2287 .withStatus(HttpStatus.SC_OK)));
2289 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2290 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2291 .withBody(mapper.writeValueAsString(serviceRecipe))
2292 .withStatus(HttpStatus.SC_OK)));
2294 uri = servInstanceuri + "v5/serviceInstances";
2295 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2297 ObjectMapper mapper = new ObjectMapper();
2298 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2299 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2301 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2302 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2303 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());