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 ch.qos.logback.classic.spi.ILoggingEvent;
25 import com.fasterxml.jackson.annotation.JsonInclude.Include;
26 import com.fasterxml.jackson.databind.DeserializationFeature;
27 import com.fasterxml.jackson.databind.ObjectMapper;
28 import com.github.tomakehurst.wiremock.http.Fault;
29 import org.apache.http.HttpStatus;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.logging.ref.slf4j.ONAPLogConstants;
33 import org.onap.so.db.catalog.beans.Service;
34 import org.onap.so.db.catalog.beans.ServiceRecipe;
35 import org.onap.so.db.request.beans.InfraActiveRequests;
36 import org.onap.so.logger.MsoLogger;
37 import org.onap.so.serviceinstancebeans.CloudConfiguration;
38 import org.onap.so.serviceinstancebeans.ModelInfo;
39 import org.onap.so.serviceinstancebeans.RequestError;
40 import org.onap.so.serviceinstancebeans.RequestParameters;
41 import org.onap.so.serviceinstancebeans.RequestReferences;
42 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
43 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.beans.factory.annotation.Value;
46 import org.springframework.http.HttpEntity;
47 import org.springframework.http.HttpMethod;
48 import org.springframework.http.ResponseEntity;
49 import org.springframework.util.ResourceUtils;
50 import org.springframework.web.util.UriComponentsBuilder;
52 import javax.ws.rs.core.HttpHeaders;
53 import javax.ws.rs.core.MediaType;
54 import javax.ws.rs.core.Response;
56 import java.io.IOException;
57 import java.nio.file.Files;
58 import java.nio.file.Paths;
59 import java.util.List;
62 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
63 import static com.github.tomakehurst.wiremock.client.WireMock.get;
64 import static com.github.tomakehurst.wiremock.client.WireMock.post;
65 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
66 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
67 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
68 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
69 import static org.junit.Assert.assertEquals;
70 import static org.junit.Assert.assertNotNull;
71 import static org.junit.Assert.assertThat;
72 import static org.junit.Assert.assertTrue;
75 public class ServiceInstancesTest extends BaseTest{
77 private final ObjectMapper mapper = new ObjectMapper();
80 private ServiceInstances servInstances;
82 @Value("${wiremock.server.port}")
83 private String wiremockPort;
85 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
86 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
90 public void beforeClass() {
91 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
92 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
93 .withStatus(HttpStatus.SC_OK)));
96 public String inputStream(String JsonInput)throws IOException{
97 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
98 return new String(Files.readAllBytes(Paths.get(JsonInput)));
101 private String getWiremockResponseForCatalogdb(String file) {
103 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
104 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
105 } catch (IOException e) {
113 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
114 headers.set("Accept", MediaType.APPLICATION_JSON);
115 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
117 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
119 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
121 return restTemplate.exchange(builder.toUriString(),
122 reqMethod, request, String.class);
126 public void test_mapJSONtoMSOStyle() throws IOException{
127 ObjectMapper mapper = new ObjectMapper();
128 mapper.setSerializationInclusion(Include.NON_NULL);
129 String testRequest= inputStream("/ServiceInstanceDefault.json");
130 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
131 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
132 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
133 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
134 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
135 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
136 assertEquals("10",modelInfo.getModelUuid());
140 public void createServiceInstanceVIDDefault() throws IOException{
141 TestAppender.events.clear();
143 ServiceRecipe serviceRecipe = new ServiceRecipe();
144 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
145 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
146 serviceRecipe.setAction(Action.createInstance.toString());
147 serviceRecipe.setId(1);
148 serviceRecipe.setRecipeTimeout(180);
149 Service defaultService = new Service();
150 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
153 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
154 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
155 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
157 stubFor(get(urlMatching(".*/service/search/.*"))
158 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
159 .withBody(mapper.writeValueAsString(defaultService))
160 .withStatus(HttpStatus.SC_OK)));
162 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
163 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
164 .withBody(mapper.writeValueAsString(serviceRecipe))
165 .withStatus(HttpStatus.SC_OK)));
167 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
168 headers.set(MsoLogger.CLIENT_ID, "VID");
170 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
171 RequestReferences requestReferences = new RequestReferences();
172 requestReferences.setInstanceId("1882939");
173 expectedResponse.setRequestReferences(requestReferences);
174 uri = servInstanceuri + "v5/serviceInstances";
175 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
177 ObjectMapper mapper = new ObjectMapper();
178 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
181 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
182 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
183 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
187 for(ILoggingEvent logEvent : TestAppender.events)
188 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
189 logEvent.getMarker().getName().equals("ENTRY")
191 Map<String,String> mdc = logEvent.getMDCPropertyMap();
192 assertNotNull(mdc.get(MsoLogger.BEGINTIME));
193 assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
194 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
195 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
196 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
197 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
198 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
199 logEvent.getMarker().getName().equals("EXIT")){
200 Map<String,String> mdc = logEvent.getMDCPropertyMap();
201 assertNotNull(mdc.get(MsoLogger.BEGINTIME));
202 assertNotNull(mdc.get(MsoLogger.ENDTIME));
203 assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
204 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
205 assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
206 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
207 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
208 assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
209 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
210 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
211 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
212 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
216 public void createServiceInstanceServiceInstancesUri() throws IOException{
217 ServiceRecipe serviceRecipe = new ServiceRecipe();
218 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
219 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
220 serviceRecipe.setAction(Action.createInstance.toString());
221 serviceRecipe.setId(1);
222 serviceRecipe.setRecipeTimeout(180);
223 Service defaultService = new Service();
224 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
226 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
227 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
228 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
231 stubFor(get(urlMatching(".*/service/search/.*"))
232 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
233 .withBody(mapper.writeValueAsString(defaultService))
234 .withStatus(HttpStatus.SC_OK)));
236 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
237 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
238 .withBody(mapper.writeValueAsString(serviceRecipe))
239 .withStatus(HttpStatus.SC_OK)));
242 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
243 RequestReferences requestReferences = new RequestReferences();
244 requestReferences.setInstanceId("1882939");
245 expectedResponse.setRequestReferences(requestReferences);
246 uri = servInstanceUriPrev7 + "v5";
247 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
249 ObjectMapper mapper = new ObjectMapper();
250 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
253 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
254 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
255 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
258 public void createServiceInstanceBpelStatusError() throws IOException{
259 ServiceRecipe serviceRecipe = new ServiceRecipe();
260 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
261 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
262 serviceRecipe.setAction(Action.createInstance.toString());
263 serviceRecipe.setId(1);
264 serviceRecipe.setRecipeTimeout(180);
265 Service defaultService = new Service();
266 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
269 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
270 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
271 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
274 stubFor(get(urlMatching(".*/service/search/.*"))
275 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
276 .withBody(mapper.writeValueAsString(defaultService))
277 .withStatus(HttpStatus.SC_OK)));
279 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
280 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
281 .withBody(mapper.writeValueAsString(serviceRecipe))
282 .withStatus(HttpStatus.SC_OK)));
284 uri = servInstanceuri + "v5/serviceInstances";
285 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
287 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
290 public void createServiceInstanceBadGateway() throws IOException{
291 ServiceRecipe serviceRecipe = new ServiceRecipe();
292 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
293 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
294 serviceRecipe.setAction(Action.createInstance.toString());
295 serviceRecipe.setId(1);
296 serviceRecipe.setRecipeTimeout(180);
297 Service defaultService = new Service();
298 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
300 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
301 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
303 stubFor(get(urlMatching(".*/service/search/.*"))
304 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
305 .withBody(mapper.writeValueAsString(defaultService))
306 .withStatus(HttpStatus.SC_OK)));
308 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
310 .withBody(mapper.writeValueAsString(serviceRecipe))
311 .withStatus(HttpStatus.SC_OK)));
313 uri = servInstanceuri + "v5/serviceInstances";
314 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
316 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
319 public void createServiceInstanceEmptyResponse() throws IOException{
320 ServiceRecipe serviceRecipe = new ServiceRecipe();
321 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
322 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
323 serviceRecipe.setAction(Action.createInstance.toString());
324 serviceRecipe.setId(1);
325 serviceRecipe.setRecipeTimeout(180);
326 Service defaultService = new Service();
327 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
329 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
330 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
332 stubFor(get(urlMatching(".*/service/search/.*"))
333 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
334 .withBody(mapper.writeValueAsString(defaultService))
335 .withStatus(HttpStatus.SC_OK)));
337 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
339 .withBody(mapper.writeValueAsString(serviceRecipe))
340 .withStatus(HttpStatus.SC_OK)));
342 uri = servInstanceuri + "v5/serviceInstances";
343 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
345 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
348 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
349 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
350 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
351 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST);
353 Service defaultService = new Service();
354 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
356 stubFor(get(urlMatching(".*/service/search/.*"))
357 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
358 .withBody(mapper.writeValueAsString(defaultService))
359 .withStatus(HttpStatus.SC_OK)));
362 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
363 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
364 .withStatus(HttpStatus.SC_NOT_FOUND)));
366 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
369 public void activateServiceInstanceNoRecipe() throws IOException{
370 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
371 Service defaultService = new Service();
372 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
373 stubFor(get(urlMatching(".*/service/search/.*"))
374 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
375 .withBody(mapper.writeValueAsString(defaultService))
376 .withStatus(HttpStatus.SC_OK)));
378 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
379 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
380 .withStatus(HttpStatus.SC_NOT_FOUND)));
382 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
384 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
387 public void activateServiceInstance() throws IOException{
388 ServiceRecipe serviceRecipe = new ServiceRecipe();
389 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
390 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
391 serviceRecipe.setAction(Action.createInstance.toString());
392 serviceRecipe.setId(1);
393 serviceRecipe.setRecipeTimeout(180);
394 Service defaultService = new Service();
395 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
397 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
398 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
399 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
401 stubFor(get(urlMatching(".*/service/search/.*"))
402 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
403 .withBody(mapper.writeValueAsString(defaultService))
404 .withStatus(HttpStatus.SC_OK)));
406 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
407 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
408 .withBody(mapper.writeValueAsString(serviceRecipe))
409 .withStatus(HttpStatus.SC_OK)));
411 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
413 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
414 RequestReferences requestReferences = new RequestReferences();
415 requestReferences.setInstanceId("1882939");
416 expectedResponse.setRequestReferences(requestReferences);
417 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
418 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST);
420 ObjectMapper mapper = new ObjectMapper();
421 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
423 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
424 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
425 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
428 public void deactivateServiceInstance() throws IOException{
430 ServiceRecipe serviceRecipe = new ServiceRecipe();
431 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
432 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
433 serviceRecipe.setAction(Action.createInstance.toString());
434 serviceRecipe.setId(1);
435 serviceRecipe.setRecipeTimeout(180);
436 Service defaultService = new Service();
437 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
439 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
440 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
441 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
443 stubFor(get(urlMatching(".*/service/.*"))
444 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
445 .withBody(mapper.writeValueAsString(defaultService))
446 .withStatus(HttpStatus.SC_OK)));
448 stubFor(get(urlMatching(".*/service/search/.*"))
449 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
450 .withBody(mapper.writeValueAsString(defaultService))
451 .withStatus(HttpStatus.SC_OK)));
453 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
454 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
455 .withBody(mapper.writeValueAsString(serviceRecipe))
456 .withStatus(HttpStatus.SC_OK)));
459 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
460 RequestReferences requestReferences = new RequestReferences();
461 requestReferences.setInstanceId("1882939");
462 expectedResponse.setRequestReferences(requestReferences);
463 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
464 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
466 ObjectMapper mapper = new ObjectMapper();
467 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
469 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
470 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
471 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
474 public void deleteServiceInstance() throws IOException {
475 ServiceRecipe serviceRecipe = new ServiceRecipe();
476 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
477 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
478 serviceRecipe.setAction(Action.createInstance.toString());
479 serviceRecipe.setId(1);
480 serviceRecipe.setRecipeTimeout(180);
481 Service defaultService = new Service();
482 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
484 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
485 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
486 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
488 stubFor(get(urlMatching(".*/service/.*"))
489 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
490 .withBody(mapper.writeValueAsString(defaultService))
491 .withStatus(HttpStatus.SC_OK)));
493 stubFor(get(urlMatching(".*/service/search/.*"))
494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
495 .withBody(mapper.writeValueAsString(defaultService))
496 .withStatus(HttpStatus.SC_OK)));
498 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
499 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
500 .withBody(mapper.writeValueAsString(serviceRecipe))
501 .withStatus(HttpStatus.SC_OK)));
503 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
504 RequestReferences requestReferences = new RequestReferences();
505 requestReferences.setInstanceId("1882939");
506 expectedResponse.setRequestReferences(requestReferences);
507 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
508 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
510 ObjectMapper mapper = new ObjectMapper();
511 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
513 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
514 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
515 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
518 public void assignServiceInstance() throws IOException {
519 ServiceRecipe serviceRecipe = new ServiceRecipe();
520 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
521 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
522 serviceRecipe.setAction(Action.createInstance.toString());
523 serviceRecipe.setId(1);
524 serviceRecipe.setRecipeTimeout(180);
525 Service defaultService = new Service();
526 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
528 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
529 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
530 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
532 stubFor(get(urlMatching(".*/service/.*"))
533 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
534 .withBody(mapper.writeValueAsString(defaultService))
535 .withStatus(HttpStatus.SC_OK)));
537 stubFor(get(urlMatching(".*/service/search/.*"))
538 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
539 .withBody(mapper.writeValueAsString(defaultService))
540 .withStatus(HttpStatus.SC_OK)));
542 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
543 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
544 .withBody(mapper.writeValueAsString(serviceRecipe))
545 .withStatus(HttpStatus.SC_OK)));
547 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
548 RequestReferences requestReferences = new RequestReferences();
549 requestReferences.setInstanceId("1882939");
550 expectedResponse.setRequestReferences(requestReferences);
551 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
552 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
554 ObjectMapper mapper = new ObjectMapper();
555 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
557 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
558 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
559 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
563 public void unassignServiceInstance() throws IOException {
564 ServiceRecipe serviceRecipe = new ServiceRecipe();
565 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
566 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
567 serviceRecipe.setAction(Action.createInstance.toString());
568 serviceRecipe.setId(1);
569 serviceRecipe.setRecipeTimeout(180);
570 Service defaultService = new Service();
571 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
573 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
574 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
575 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
577 stubFor(get(urlMatching(".*/service/.*"))
578 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
579 .withBody(mapper.writeValueAsString(defaultService))
580 .withStatus(HttpStatus.SC_OK)));
582 stubFor(get(urlMatching(".*/service/search/.*"))
583 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
584 .withBody(mapper.writeValueAsString(defaultService))
585 .withStatus(HttpStatus.SC_OK)));
587 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
588 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
589 .withBody(mapper.writeValueAsString(serviceRecipe))
590 .withStatus(HttpStatus.SC_OK)));
592 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
593 RequestReferences requestReferences = new RequestReferences();
594 requestReferences.setInstanceId("1882939");
595 expectedResponse.setRequestReferences(requestReferences);
596 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
597 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
599 ObjectMapper mapper = new ObjectMapper();
600 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
602 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
603 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
604 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
607 public void createPortConfiguration() throws IOException {
608 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
609 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
610 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
611 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
613 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
614 RequestReferences requestReferences = new RequestReferences();
615 requestReferences.setInstanceId("1882939");
616 expectedResponse.setRequestReferences(requestReferences);
617 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
618 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST);
620 ObjectMapper mapper = new ObjectMapper();
621 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
623 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
624 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
625 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
626 assertTrue(response.getBody().contains("1882939"));
629 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
630 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
631 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
633 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
636 public void deletePortConfiguration() throws IOException {
637 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
638 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
639 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
641 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
643 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
644 RequestReferences requestReferences = new RequestReferences();
645 requestReferences.setInstanceId("1882939");
646 expectedResponse.setRequestReferences(requestReferences);
647 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
648 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE);
650 ObjectMapper mapper = new ObjectMapper();
651 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
653 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
654 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
655 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
658 public void enablePort() throws IOException {
659 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
660 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
661 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
663 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
664 RequestReferences requestReferences = new RequestReferences();
665 requestReferences.setInstanceId("1882939");
666 expectedResponse.setRequestReferences(requestReferences);
667 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
668 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
670 ObjectMapper mapper = new ObjectMapper();
671 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
673 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
674 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
675 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
678 public void disablePort() throws IOException {
679 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
680 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
681 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
683 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
684 RequestReferences requestReferences = new RequestReferences();
685 requestReferences.setInstanceId("1882939");
686 expectedResponse.setRequestReferences(requestReferences);
687 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
688 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
690 ObjectMapper mapper = new ObjectMapper();
691 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
693 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
694 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
695 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
698 public void activatePort() throws IOException {
699 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
700 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
701 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
703 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
704 RequestReferences requestReferences = new RequestReferences();
705 requestReferences.setInstanceId("1882939");
706 expectedResponse.setRequestReferences(requestReferences);
707 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
708 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
710 ObjectMapper mapper = new ObjectMapper();
711 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
713 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
714 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
715 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
718 public void deactivatePort() throws IOException {
719 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
720 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
721 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
723 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
724 RequestReferences requestReferences = new RequestReferences();
725 requestReferences.setInstanceId("1882939");
726 expectedResponse.setRequestReferences(requestReferences);
727 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
728 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
730 ObjectMapper mapper = new ObjectMapper();
731 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
733 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
734 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
735 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
738 public void addRelationships() throws IOException {
739 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
740 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
741 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
744 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
745 RequestReferences requestReferences = new RequestReferences();
746 requestReferences.setInstanceId("1882939");
747 expectedResponse.setRequestReferences(requestReferences);
748 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
749 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
751 ObjectMapper mapper = new ObjectMapper();
752 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
754 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
755 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
756 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
759 public void removeRelationships() throws IOException {
760 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
761 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
762 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
765 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
766 RequestReferences requestReferences = new RequestReferences();
767 requestReferences.setInstanceId("1882939");
768 expectedResponse.setRequestReferences(requestReferences);
769 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
770 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
772 ObjectMapper mapper = new ObjectMapper();
773 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
775 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
776 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
777 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
780 public void createVnfInstanceNoALaCarte() throws IOException {
781 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
782 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
783 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
786 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
787 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
788 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
789 .withStatus(org.apache.http.HttpStatus.SC_OK)));
791 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
792 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
793 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
794 .withStatus(org.apache.http.HttpStatus.SC_OK)));
796 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
797 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
798 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
799 .withStatus(org.apache.http.HttpStatus.SC_OK)));
802 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
803 RequestReferences requestReferences = new RequestReferences();
804 requestReferences.setInstanceId("1882939");
805 expectedResponse.setRequestReferences(requestReferences);
806 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
807 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
809 ObjectMapper mapper = new ObjectMapper();
810 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
812 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
813 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
814 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
817 public void createVnfInstance() throws IOException {
818 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
819 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
820 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
822 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
823 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
824 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
825 .withStatus(org.apache.http.HttpStatus.SC_OK)));
826 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
827 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
828 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
829 .withStatus(org.apache.http.HttpStatus.SC_OK)));
832 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
833 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
834 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
835 .withStatus(org.apache.http.HttpStatus.SC_OK)));
837 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
838 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
839 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
840 .withStatus(org.apache.http.HttpStatus.SC_OK)));
842 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
843 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
845 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
846 RequestReferences requestReferences = new RequestReferences();
847 requestReferences.setInstanceId("1882939");
848 expectedResponse.setRequestReferences(requestReferences);
849 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
850 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST);
852 ObjectMapper mapper = new ObjectMapper();
853 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
855 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
856 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
857 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
858 assertTrue(response.getBody().contains("1882939"));
861 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
862 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
863 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
865 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
868 public void createVnfInstanceInvalidVnfResource() throws IOException {
869 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
870 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
872 ObjectMapper mapper = new ObjectMapper();
873 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
874 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
876 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
877 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
878 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
881 public void replaceVnfInstance() throws IOException {
882 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
883 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
884 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
886 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
887 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
888 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
889 .withStatus(org.apache.http.HttpStatus.SC_OK)));
891 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
892 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
893 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
894 .withStatus(org.apache.http.HttpStatus.SC_OK)));
896 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
897 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
898 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
899 .withStatus(org.apache.http.HttpStatus.SC_OK)));
901 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
902 RequestReferences requestReferences = new RequestReferences();
903 requestReferences.setInstanceId("1882939");
904 expectedResponse.setRequestReferences(requestReferences);
905 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
906 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
908 ObjectMapper mapper = new ObjectMapper();
909 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
911 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
912 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
913 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
916 public void replaceVnfRecreateInstance() throws IOException {
917 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
918 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
919 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
921 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
922 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
923 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
924 .withStatus(org.apache.http.HttpStatus.SC_OK)));
926 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
927 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
928 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
929 .withStatus(org.apache.http.HttpStatus.SC_OK)));
931 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
932 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
933 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
934 .withStatus(org.apache.http.HttpStatus.SC_OK)));
937 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
938 RequestReferences requestReferences = new RequestReferences();
939 requestReferences.setInstanceId("1882939");
940 expectedResponse.setRequestReferences(requestReferences);
941 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
942 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
943 logger.debug(response.getBody());
944 ObjectMapper mapper = new ObjectMapper();
945 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
947 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
948 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
949 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
952 public void updateVnfInstance() throws IOException {
953 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
954 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
955 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
957 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
958 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
959 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
960 .withStatus(org.apache.http.HttpStatus.SC_OK)));
962 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
963 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
964 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
965 .withStatus(org.apache.http.HttpStatus.SC_OK)));
967 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
968 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
969 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
970 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
971 .withStatus(org.apache.http.HttpStatus.SC_OK)));
974 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
975 RequestReferences requestReferences = new RequestReferences();
976 requestReferences.setInstanceId("1882939");
977 expectedResponse.setRequestReferences(requestReferences);
978 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
979 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
981 ObjectMapper mapper = new ObjectMapper();
982 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
984 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
985 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
986 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
989 public void applyUpdatedConfig() throws IOException {
990 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
991 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
992 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
995 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
996 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
997 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
998 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
999 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1001 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
1002 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1004 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1005 RequestReferences requestReferences = new RequestReferences();
1006 requestReferences.setInstanceId("1882939");
1007 expectedResponse.setRequestReferences(requestReferences);
1008 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1009 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST);
1011 ObjectMapper mapper = new ObjectMapper();
1012 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1014 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1015 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1016 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1019 public void deleteVnfInstanceV5() throws IOException {
1020 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1021 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1022 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1024 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1025 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1026 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1027 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1028 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1030 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1031 RequestReferences requestReferences = new RequestReferences();
1032 requestReferences.setInstanceId("1882939");
1033 expectedResponse.setRequestReferences(requestReferences);
1034 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1035 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
1037 ObjectMapper mapper = new ObjectMapper();
1038 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1040 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1041 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1042 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1045 public void createVfModuleInstance() throws IOException {
1047 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1048 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1049 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1050 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1052 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1053 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1054 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1055 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1057 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1058 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1059 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1060 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1062 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1063 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1064 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1066 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1067 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1068 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1069 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1070 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1072 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1073 RequestReferences requestReferences = new RequestReferences();
1074 requestReferences.setInstanceId("1882939");
1075 expectedResponse.setRequestReferences(requestReferences);
1076 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1077 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
1079 ObjectMapper mapper = new ObjectMapper();
1080 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1082 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1083 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1084 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1085 assertTrue(response.getBody().contains("1882939"));
1088 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1089 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1090 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1091 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1093 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1094 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1095 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1096 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1098 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1099 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1100 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1101 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1102 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1104 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1105 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1106 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1107 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1109 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1110 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1111 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1112 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1113 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1115 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1116 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1117 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1118 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1120 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1121 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1122 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1123 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1126 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1127 "[?]vnfComponentType=vfModule&action=createInstance"))
1128 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1129 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1130 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1133 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1134 RequestReferences requestReferences = new RequestReferences();
1135 requestReferences.setInstanceId("1882939");
1136 expectedResponse.setRequestReferences(requestReferences);
1137 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1138 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
1139 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1140 ObjectMapper mapper = new ObjectMapper();
1141 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1142 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1145 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1146 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1147 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1148 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1150 stubFor(get(urlMatching(".*/vnfResource/.*"))
1151 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1152 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1153 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1155 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1156 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1157 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1158 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1160 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1161 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1162 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1163 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1165 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1166 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1167 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1168 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1170 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1171 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1172 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1173 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1175 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1176 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1177 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1178 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1180 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1181 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1182 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1183 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1184 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1187 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1188 RequestReferences requestReferences = new RequestReferences();
1189 requestReferences.setInstanceId("1882939");
1190 expectedResponse.setRequestReferences(requestReferences);
1191 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1192 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
1194 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1195 ObjectMapper mapper = new ObjectMapper();
1196 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1197 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1200 public void createVfModuleInstanceNoRecipe() throws IOException {
1202 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
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 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1209 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1210 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1211 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1213 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1214 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1215 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1216 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1218 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1219 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1220 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1221 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1222 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1224 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1225 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
1227 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1228 ObjectMapper mapper = new ObjectMapper();
1229 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1230 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1231 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1234 public void replaceVfModuleInstance() throws IOException {
1235 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1236 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1237 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1239 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1240 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1241 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1242 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1243 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1245 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1246 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1247 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1248 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1249 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1251 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1252 RequestReferences requestReferences = new RequestReferences();
1253 requestReferences.setInstanceId("1882939");
1254 expectedResponse.setRequestReferences(requestReferences);
1255 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1256 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
1258 ObjectMapper mapper = new ObjectMapper();
1259 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1261 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1262 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1263 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1266 public void updateVfModuleInstance() throws IOException {
1267 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1268 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1269 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1271 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1272 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1273 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1274 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1276 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1277 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1278 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1279 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1281 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1282 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1283 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1284 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1286 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1287 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1288 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1289 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1290 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1293 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1294 RequestReferences requestReferences = new RequestReferences();
1295 requestReferences.setInstanceId("1882939");
1296 expectedResponse.setRequestReferences(requestReferences);
1297 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1298 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
1299 logger.debug(response.getBody());
1301 ObjectMapper mapper = new ObjectMapper();
1302 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1304 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1305 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1306 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1309 public void createVfModuleNoModelType() throws IOException{
1310 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1311 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1312 expectedRecord.setRequestStatus("FAILED");
1313 expectedRecord.setAction("createInstance");
1314 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1315 expectedRecord.setProgress(100L);
1316 expectedRecord.setSource("VID");
1317 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1318 expectedRecord.setLastModifiedBy("APIH");
1319 expectedRecord.setVfModuleName("testVfModule2");
1320 expectedRecord.setVfModuleModelName("serviceModel");
1321 expectedRecord.setRequestScope("vfModule");
1322 expectedRecord.setRequestAction("createInstance");
1323 expectedRecord.setRequestorId("zz9999");
1324 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1325 //VnfType is not sent in this request, should be blank in db
1326 expectedRecord.setVnfType("");
1327 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1329 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST);
1331 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1334 public void inPlaceSoftwareUpdate() throws IOException {
1335 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1336 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1337 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1339 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1340 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1341 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1342 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1343 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1346 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1347 RequestReferences requestReferences = new RequestReferences();
1348 requestReferences.setInstanceId("1882939");
1349 expectedResponse.setRequestReferences(requestReferences);
1350 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1351 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
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"));
1362 public void deleteVfModuleInstance() throws IOException {
1363 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1365 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1367 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1368 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1369 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1370 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1371 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1373 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1374 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1375 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1376 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1377 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1380 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1381 RequestReferences requestReferences = new RequestReferences();
1382 requestReferences.setInstanceId("1882939");
1383 expectedResponse.setRequestReferences(requestReferences);
1384 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1385 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
1387 ObjectMapper mapper = new ObjectMapper();
1388 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1390 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1391 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1392 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1395 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1396 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1397 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1398 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1400 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1401 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1402 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1403 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1404 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1406 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1407 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1408 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1409 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1410 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1413 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1414 RequestReferences requestReferences = new RequestReferences();
1415 requestReferences.setInstanceId("1882939");
1416 expectedResponse.setRequestReferences(requestReferences);
1417 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1418 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
1420 ObjectMapper mapper = new ObjectMapper();
1421 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1423 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1424 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1425 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1428 public void createVolumeGroupInstance() throws IOException {
1429 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1430 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1431 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1433 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1434 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1435 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1436 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1438 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1439 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1440 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1441 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1443 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1444 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1445 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1446 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1447 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1450 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1451 RequestReferences requestReferences = new RequestReferences();
1452 requestReferences.setInstanceId("1882939");
1453 expectedResponse.setRequestReferences(requestReferences);
1454 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1455 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
1457 ObjectMapper mapper = new ObjectMapper();
1458 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1460 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1461 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1462 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1463 assertTrue(response.getBody().contains("1882939"));
1466 public void updateVolumeGroupInstance() throws IOException {
1467 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1468 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1469 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1471 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1472 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1473 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1474 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1476 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1477 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1478 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1479 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1481 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1482 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1483 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1484 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1485 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1488 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1489 RequestReferences requestReferences = new RequestReferences();
1490 requestReferences.setInstanceId("1882939");
1491 expectedResponse.setRequestReferences(requestReferences);
1492 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1493 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
1495 ObjectMapper mapper = new ObjectMapper();
1496 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1498 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1499 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1500 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1503 public void deleteVolumeGroupInstance() throws IOException {
1504 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1505 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1506 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1508 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1509 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1510 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1512 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1513 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1514 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1515 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1517 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1518 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1519 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1520 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1522 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1523 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1524 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1525 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1526 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1529 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1530 RequestReferences requestReferences = new RequestReferences();
1531 requestReferences.setInstanceId("1882939");
1532 expectedResponse.setRequestReferences(requestReferences);
1533 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1534 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
1536 ObjectMapper mapper = new ObjectMapper();
1537 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1539 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1540 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1541 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1544 public void createNetworkInstance() throws IOException {
1545 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1546 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1547 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1549 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1551 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1552 .withStatus(HttpStatus.SC_OK)));
1554 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1555 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1556 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1557 .withStatus(HttpStatus.SC_OK)));
1559 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1560 "modelName=GR-API-DEFAULT&action=createInstance"))
1561 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1562 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1563 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1565 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
1566 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
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-0050569a7969/networks";
1573 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST);
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 updateNetworkInstance() 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(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1589 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1590 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1591 .withStatus(HttpStatus.SC_OK)));
1593 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1594 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1595 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1596 .withStatus(HttpStatus.SC_OK)));
1598 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1599 "modelName=GR-API-DEFAULT&action=updateInstance"))
1600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1601 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1602 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1604 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1605 RequestReferences requestReferences = new RequestReferences();
1606 requestReferences.setInstanceId("1882939");
1607 expectedResponse.setRequestReferences(requestReferences);
1608 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1609 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
1611 ObjectMapper mapper = new ObjectMapper();
1612 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1614 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1615 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1616 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1617 assertTrue(response.getBody().contains("1882939"));
1620 public void deleteNetworkInstance() throws IOException {
1621 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1622 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1623 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1625 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1626 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1627 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1628 .withStatus(HttpStatus.SC_OK)));
1630 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1631 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1632 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1633 .withStatus(HttpStatus.SC_OK)));
1635 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1636 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1637 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1638 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1639 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1642 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1643 RequestReferences requestReferences = new RequestReferences();
1644 requestReferences.setInstanceId("1882939");
1645 expectedResponse.setRequestReferences(requestReferences);
1646 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1647 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
1649 ObjectMapper mapper = new ObjectMapper();
1650 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1652 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1653 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1654 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1657 public void deleteNetworkInstanceNoReqParams() throws IOException {
1658 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1659 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1660 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1662 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1663 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1664 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1665 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1666 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1670 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1671 RequestReferences requestReferences = new RequestReferences();
1672 requestReferences.setInstanceId("1882939");
1673 expectedResponse.setRequestReferences(requestReferences);
1674 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1675 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
1677 ObjectMapper mapper = new ObjectMapper();
1678 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1680 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1681 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1682 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1685 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1686 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1688 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1689 expectedRecord.setRequestStatus("FAILED");
1690 expectedRecord.setStatusMessage("Error mapping request: ");
1691 expectedRecord.setProgress(100L);
1692 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1693 expectedRecord.setLastModifiedBy("APIH");
1694 expectedRecord.setRequestScope("network");
1695 expectedRecord.setRequestAction("deleteInstance");
1696 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1698 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1699 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE);
1703 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1706 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1707 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1708 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1710 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1714 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1715 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1716 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1717 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1719 ServiceRecipe serviceRecipe = new ServiceRecipe();
1720 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1721 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1722 serviceRecipe.setAction(Action.createInstance.toString());
1723 serviceRecipe.setId(1);
1724 serviceRecipe.setRecipeTimeout(180);
1725 Service defaultService = new Service();
1726 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1728 stubFor(get(urlMatching(".*/service/.*"))
1729 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1730 .withBody(mapper.writeValueAsString(defaultService))
1731 .withStatus(HttpStatus.SC_OK)));
1733 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1734 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1735 .withBody(mapper.writeValueAsString(serviceRecipe))
1736 .withStatus(HttpStatus.SC_OK)));
1738 uri = servInstanceuri + "v7" + "/serviceInstances";
1739 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
1742 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1743 RequestReferences requestReferences = new RequestReferences();
1744 requestReferences.setInstanceId("1882939");
1745 expectedResponse.setRequestReferences(requestReferences);
1747 ObjectMapper mapper = new ObjectMapper();
1748 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1750 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1751 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1752 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1756 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1757 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1758 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1759 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1761 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1762 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1763 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1764 .withStatus(HttpStatus.SC_OK)));
1766 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1767 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1768 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1769 .withStatus(HttpStatus.SC_OK)));
1771 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1772 "modelName=GR-API-DEFAULT&action=createInstance"))
1773 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1774 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1775 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1777 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1778 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
1781 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1782 RequestReferences requestReferences = new RequestReferences();
1783 requestReferences.setInstanceId("1882939");
1784 expectedResponse.setRequestReferences(requestReferences);
1786 ObjectMapper mapper = new ObjectMapper();
1787 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1789 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1790 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1791 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1795 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1796 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1797 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1798 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1800 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1801 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1804 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1805 RequestReferences requestReferences = new RequestReferences();
1806 requestReferences.setInstanceId("1882939");
1807 expectedResponse.setRequestReferences(requestReferences);
1809 ObjectMapper mapper = new ObjectMapper();
1810 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1812 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1816 public void createNetworkInstanceTestApiGrApi() throws IOException {
1817 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1818 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1819 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1821 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1822 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1823 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1824 .withStatus(HttpStatus.SC_OK)));
1826 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1827 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1828 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1829 .withStatus(HttpStatus.SC_OK)));
1831 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1832 "modelName=GR-API-DEFAULT&action=createInstance"))
1833 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1834 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1835 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1837 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1838 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
1841 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1842 RequestReferences requestReferences = new RequestReferences();
1843 requestReferences.setInstanceId("1882939");
1844 expectedResponse.setRequestReferences(requestReferences);
1846 ObjectMapper mapper = new ObjectMapper();
1847 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1849 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1850 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1851 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1855 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1856 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1857 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1858 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1860 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1861 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1862 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1863 .withStatus(HttpStatus.SC_OK)));
1865 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1866 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1867 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1868 .withStatus(HttpStatus.SC_OK)));
1870 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1871 "modelName=VNF-API-DEFAULT&action=createInstance"))
1872 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1873 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1874 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1876 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1877 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
1880 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1881 RequestReferences requestReferences = new RequestReferences();
1882 requestReferences.setInstanceId("1882939");
1883 expectedResponse.setRequestReferences(requestReferences);
1885 ObjectMapper mapper = new ObjectMapper();
1886 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1888 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1889 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1890 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1894 public void activateServiceInstanceRequestStatus() throws IOException{
1895 ServiceRecipe serviceRecipe = new ServiceRecipe();
1896 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1897 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1898 serviceRecipe.setAction(Action.createInstance.toString());
1899 serviceRecipe.setId(1);
1900 serviceRecipe.setRecipeTimeout(180);
1901 Service defaultService = new Service();
1902 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1904 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1905 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1906 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1907 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
1909 stubFor(get(urlMatching(".*/service/.*"))
1910 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1911 .withBody(mapper.writeValueAsString(defaultService))
1912 .withStatus(HttpStatus.SC_OK)));
1914 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1915 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1916 .withBody(mapper.writeValueAsString(serviceRecipe))
1917 .withStatus(HttpStatus.SC_OK)));
1920 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1921 RequestReferences requestReferences = new RequestReferences();
1922 requestReferences.setInstanceId("1882939");
1923 expectedResponse.setRequestReferences(requestReferences);
1924 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
1925 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST);
1927 ObjectMapper mapper = new ObjectMapper();
1928 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1930 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1931 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1932 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1936 public void invalidRequestId() throws IOException {
1937 String illegalRequestId = "1234";
1938 headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
1940 uri = servInstanceuri + "v5/serviceInstances";
1941 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
1943 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1944 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
1947 public void invalidBPELResponse() throws IOException{
1949 ServiceRecipe serviceRecipe = new ServiceRecipe();
1950 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1951 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1952 serviceRecipe.setAction(Action.createInstance.toString());
1953 serviceRecipe.setId(1);
1954 serviceRecipe.setRecipeTimeout(180);
1955 Service defaultService = new Service();
1956 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1958 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1959 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1960 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1962 stubFor(get(urlMatching(".*/service/.*"))
1963 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1964 .withBody(mapper.writeValueAsString(defaultService))
1965 .withStatus(HttpStatus.SC_OK)));
1967 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1968 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1969 .withBody(mapper.writeValueAsString(serviceRecipe))
1970 .withStatus(HttpStatus.SC_OK)));
1972 uri = servInstanceuri + "v5/serviceInstances";
1973 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
1975 ObjectMapper mapper = new ObjectMapper();
1976 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1977 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1979 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1980 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1981 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
1985 public void invalidBPELResponse2() throws IOException{
1987 ServiceRecipe serviceRecipe = new ServiceRecipe();
1988 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1989 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1990 serviceRecipe.setAction(Action.createInstance.toString());
1991 serviceRecipe.setId(1);
1992 serviceRecipe.setRecipeTimeout(180);
1993 Service defaultService = new Service();
1994 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1996 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1997 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1998 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2000 stubFor(get(urlMatching(".*/service/.*"))
2001 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2002 .withBody(mapper.writeValueAsString(defaultService))
2003 .withStatus(HttpStatus.SC_OK)));
2005 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2006 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2007 .withBody(mapper.writeValueAsString(serviceRecipe))
2008 .withStatus(HttpStatus.SC_OK)));
2009 uri = servInstanceuri + "v5/serviceInstances";
2010 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2012 ObjectMapper mapper = new ObjectMapper();
2013 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2014 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2016 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2017 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2018 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2022 public void createMacroServiceInstance() throws IOException{
2023 ServiceRecipe serviceRecipe = new ServiceRecipe();
2024 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2025 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2026 serviceRecipe.setAction(Action.createInstance.toString());
2027 serviceRecipe.setId(1);
2028 serviceRecipe.setRecipeTimeout(180);
2029 Service defaultService = new Service();
2030 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2032 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2033 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2034 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2036 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2037 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2038 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2040 stubFor(get(urlMatching(".*/service/.*"))
2041 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2042 .withBody(mapper.writeValueAsString(defaultService))
2043 .withStatus(HttpStatus.SC_OK)));
2045 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2046 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2047 .withBody(mapper.writeValueAsString(serviceRecipe))
2048 .withStatus(HttpStatus.SC_OK)));
2051 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2052 RequestReferences requestReferences = new RequestReferences();
2053 requestReferences.setInstanceId("1882939");
2054 expectedResponse.setRequestReferences(requestReferences);
2055 uri = servInstanceUriPrev7 + "v5";
2056 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
2058 ObjectMapper mapper = new ObjectMapper();
2059 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2062 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2063 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2064 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2068 public void testUserParams() throws IOException {
2069 ObjectMapper mapper = new ObjectMapper();
2070 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2071 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2072 String userParamsTxt = inputStream("/userParams.txt");
2074 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2075 System.out.println(userParams);
2076 assertTrue(userParams.size() > 0);
2077 assertTrue(userParams.get(0).containsKey("name"));
2078 assertTrue(userParams.get(0).containsKey("value"));
2079 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2083 public void testConfigureCloudConfig() throws IOException {
2084 ObjectMapper mapper = new ObjectMapper();
2085 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2086 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2088 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2089 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2093 public void testMapToLegacyRequest() throws IOException {
2094 ObjectMapper mapper = new ObjectMapper();
2095 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2096 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2097 servInstances.mapToLegacyRequest(request.getRequestDetails());
2098 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2099 assertThat(request, sameBeanAs(expected));
2102 public void scaleOutVfModule() throws IOException {
2103 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2104 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2105 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2107 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2108 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2109 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2110 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2112 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2113 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2114 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2115 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2117 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2118 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2119 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2120 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2123 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2124 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2125 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2126 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2128 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2129 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2130 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2133 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2134 RequestReferences requestReferences = new RequestReferences();
2135 requestReferences.setInstanceId("1882939");
2136 expectedResponse.setRequestReferences(requestReferences);
2137 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2138 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST);
2140 ObjectMapper mapper = new ObjectMapper();
2141 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2143 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2144 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2145 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2146 assertTrue(response.getBody().contains("1882939"));