2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.apihandlerinfra;
24 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
25 import static com.github.tomakehurst.wiremock.client.WireMock.get;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
29 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
30 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
31 import static org.junit.Assert.assertEquals;
32 import static org.junit.Assert.assertNotNull;
33 import static org.junit.Assert.assertThat;
34 import static org.junit.Assert.assertTrue;
37 import java.io.IOException;
39 import java.nio.file.Files;
40 import java.nio.file.Paths;
41 import java.util.List;
44 import javax.ws.rs.core.MediaType;
45 import javax.ws.rs.core.Response;
47 import org.apache.http.HttpStatus;
48 import org.junit.Before;
49 import org.junit.Ignore;
50 import org.junit.Test;
51 import org.onap.logging.ref.slf4j.ONAPLogConstants;
52 import org.onap.so.db.catalog.beans.Service;
53 import org.onap.so.db.catalog.beans.ServiceRecipe;
54 import org.onap.so.db.request.beans.InfraActiveRequests;
55 import org.onap.so.logger.MsoLogger;
56 import org.onap.so.serviceinstancebeans.CloudConfiguration;
57 import org.onap.so.serviceinstancebeans.ModelInfo;
58 import org.onap.so.serviceinstancebeans.RequestDetails;
59 import org.onap.so.serviceinstancebeans.RequestError;
60 import org.onap.so.serviceinstancebeans.RequestInfo;
61 import org.onap.so.serviceinstancebeans.RequestParameters;
62 import org.onap.so.serviceinstancebeans.RequestReferences;
63 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
64 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
65 import org.springframework.beans.factory.annotation.Autowired;
66 import org.springframework.beans.factory.annotation.Value;
67 import org.springframework.http.HttpEntity;
68 import org.springframework.http.HttpHeaders;
69 import org.springframework.http.HttpMethod;
70 import org.springframework.http.ResponseEntity;
71 import org.springframework.util.ResourceUtils;
72 import org.springframework.web.util.UriComponentsBuilder;
74 import com.fasterxml.jackson.annotation.JsonInclude.Include;
75 import com.fasterxml.jackson.core.JsonProcessingException;
76 import com.fasterxml.jackson.databind.DeserializationFeature;
77 import com.fasterxml.jackson.databind.ObjectMapper;
78 import com.github.tomakehurst.wiremock.http.Fault;
80 import ch.qos.logback.classic.spi.ILoggingEvent;
83 public class ServiceInstancesTest extends BaseTest{
85 private final ObjectMapper mapper = new ObjectMapper();
88 private ServiceInstances servInstances;
90 @Value("${wiremock.server.port}")
91 private String wiremockPort;
93 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
94 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
98 public void beforeClass() {
99 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
100 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
101 .withStatus(HttpStatus.SC_OK)));
104 public String inputStream(String JsonInput)throws IOException{
105 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
106 return new String(Files.readAllBytes(Paths.get(JsonInput)));
109 private String getWiremockResponseForCatalogdb(String file) {
111 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
112 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
113 } catch (IOException e) {
120 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
122 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
123 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
125 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
126 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
129 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath));
131 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
133 return restTemplate.exchange(builder.toUriString(),
134 reqMethod, request, String.class);
137 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
138 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
142 public void test_mapJSONtoMSOStyle() throws IOException{
143 ObjectMapper mapper = new ObjectMapper();
144 mapper.setSerializationInclusion(Include.NON_NULL);
145 String testRequest= inputStream("/ServiceInstanceDefault.json");
146 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
147 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
148 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
149 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
150 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
151 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
152 assertEquals("10",modelInfo.getModelUuid());
156 public void createServiceInstanceVIDDefault() throws IOException{
157 TestAppender.events.clear();
159 ServiceRecipe serviceRecipe = new ServiceRecipe();
160 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
161 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
162 serviceRecipe.setAction(Action.createInstance.toString());
163 serviceRecipe.setId(1);
164 serviceRecipe.setRecipeTimeout(180);
165 Service defaultService = new Service();
166 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
169 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
170 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
171 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
173 stubFor(get(urlMatching(".*/service/search/.*"))
174 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
175 .withBody(mapper.writeValueAsString(defaultService))
176 .withStatus(HttpStatus.SC_OK)));
178 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
179 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
180 .withBody(mapper.writeValueAsString(serviceRecipe))
181 .withStatus(HttpStatus.SC_OK)));
182 HttpHeaders headers = new HttpHeaders();
183 headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
184 headers.set(MsoLogger.CLIENT_ID, "VID");
186 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
187 RequestReferences requestReferences = new RequestReferences();
188 requestReferences.setInstanceId("1882939");
189 expectedResponse.setRequestReferences(requestReferences);
190 uri = servInstanceuri + "v5/serviceInstances";
191 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
193 ObjectMapper mapper = new ObjectMapper();
194 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
197 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
198 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
199 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
203 for(ILoggingEvent logEvent : TestAppender.events)
204 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
205 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
207 Map<String,String> mdc = logEvent.getMDCPropertyMap();
208 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
209 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
210 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
211 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
212 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
213 assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
214 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
215 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
216 Map<String,String> mdc = logEvent.getMDCPropertyMap();
217 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
218 assertNotNull(mdc.get(MsoLogger.ENDTIME));
219 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
220 assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
221 assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
222 assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
223 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
224 assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE));
225 assertNotNull(mdc.get(MsoLogger.RESPONSEDESC));
226 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
227 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
228 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
232 public void createServiceInstanceServiceInstancesUri() throws IOException{
233 ServiceRecipe serviceRecipe = new ServiceRecipe();
234 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
235 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
236 serviceRecipe.setAction(Action.createInstance.toString());
237 serviceRecipe.setId(1);
238 serviceRecipe.setRecipeTimeout(180);
239 Service defaultService = new Service();
240 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
242 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
243 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
244 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
247 stubFor(get(urlMatching(".*/service/search/.*"))
248 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
249 .withBody(mapper.writeValueAsString(defaultService))
250 .withStatus(HttpStatus.SC_OK)));
252 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
253 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
254 .withBody(mapper.writeValueAsString(serviceRecipe))
255 .withStatus(HttpStatus.SC_OK)));
258 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
259 RequestReferences requestReferences = new RequestReferences();
260 requestReferences.setInstanceId("1882939");
261 expectedResponse.setRequestReferences(requestReferences);
262 uri = servInstanceUriPrev7 + "v5";
263 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST);
265 ObjectMapper mapper = new ObjectMapper();
266 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
269 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
270 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
271 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
274 public void createServiceInstanceBpelStatusError() throws IOException{
275 ServiceRecipe serviceRecipe = new ServiceRecipe();
276 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
277 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
278 serviceRecipe.setAction(Action.createInstance.toString());
279 serviceRecipe.setId(1);
280 serviceRecipe.setRecipeTimeout(180);
281 Service defaultService = new Service();
282 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
285 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
286 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
287 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
290 stubFor(get(urlMatching(".*/service/search/.*"))
291 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
292 .withBody(mapper.writeValueAsString(defaultService))
293 .withStatus(HttpStatus.SC_OK)));
295 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
296 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
297 .withBody(mapper.writeValueAsString(serviceRecipe))
298 .withStatus(HttpStatus.SC_OK)));
300 uri = servInstanceuri + "v5/serviceInstances";
301 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
303 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
306 public void createServiceInstanceBadGateway() throws IOException{
307 ServiceRecipe serviceRecipe = new ServiceRecipe();
308 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
309 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
310 serviceRecipe.setAction(Action.createInstance.toString());
311 serviceRecipe.setId(1);
312 serviceRecipe.setRecipeTimeout(180);
313 Service defaultService = new Service();
314 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
316 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
317 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
319 stubFor(get(urlMatching(".*/service/search/.*"))
320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
321 .withBody(mapper.writeValueAsString(defaultService))
322 .withStatus(HttpStatus.SC_OK)));
324 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
325 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
326 .withBody(mapper.writeValueAsString(serviceRecipe))
327 .withStatus(HttpStatus.SC_OK)));
329 uri = servInstanceuri + "v5/serviceInstances";
330 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
332 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
335 public void createServiceInstanceEmptyResponse() throws IOException{
336 ServiceRecipe serviceRecipe = new ServiceRecipe();
337 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
338 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
339 serviceRecipe.setAction(Action.createInstance.toString());
340 serviceRecipe.setId(1);
341 serviceRecipe.setRecipeTimeout(180);
342 Service defaultService = new Service();
343 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
345 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
346 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
348 stubFor(get(urlMatching(".*/service/search/.*"))
349 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
350 .withBody(mapper.writeValueAsString(defaultService))
351 .withStatus(HttpStatus.SC_OK)));
353 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
354 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
355 .withBody(mapper.writeValueAsString(serviceRecipe))
356 .withStatus(HttpStatus.SC_OK)));
358 uri = servInstanceuri + "v5/serviceInstances";
359 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
361 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
364 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
365 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
366 HttpHeaders headers = new HttpHeaders();
367 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
368 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, headers);
370 Service defaultService = new Service();
371 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)));
379 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
380 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
381 .withStatus(HttpStatus.SC_NOT_FOUND)));
383 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
386 public void activateServiceInstanceNoRecipe() throws IOException{
387 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
388 Service defaultService = new Service();
389 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
390 stubFor(get(urlMatching(".*/service/search/.*"))
391 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
392 .withBody(mapper.writeValueAsString(defaultService))
393 .withStatus(HttpStatus.SC_OK)));
395 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
396 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
397 .withStatus(HttpStatus.SC_NOT_FOUND)));
399 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
401 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
404 public void activateServiceInstance() throws IOException{
405 ServiceRecipe serviceRecipe = new ServiceRecipe();
406 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
407 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
408 serviceRecipe.setAction(Action.createInstance.toString());
409 serviceRecipe.setId(1);
410 serviceRecipe.setRecipeTimeout(180);
411 Service defaultService = new Service();
412 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
414 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
415 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
416 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
418 stubFor(get(urlMatching(".*/service/search/.*"))
419 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
420 .withBody(mapper.writeValueAsString(defaultService))
421 .withStatus(HttpStatus.SC_OK)));
423 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
424 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
425 .withBody(mapper.writeValueAsString(serviceRecipe))
426 .withStatus(HttpStatus.SC_OK)));
427 HttpHeaders headers = new HttpHeaders();
428 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
430 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
431 RequestReferences requestReferences = new RequestReferences();
432 requestReferences.setInstanceId("1882939");
433 expectedResponse.setRequestReferences(requestReferences);
434 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
435 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
437 ObjectMapper mapper = new ObjectMapper();
438 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
440 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
441 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
442 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
445 public void deactivateServiceInstance() throws IOException{
447 ServiceRecipe serviceRecipe = new ServiceRecipe();
448 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
449 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
450 serviceRecipe.setAction(Action.createInstance.toString());
451 serviceRecipe.setId(1);
452 serviceRecipe.setRecipeTimeout(180);
453 Service defaultService = new Service();
454 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
456 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
457 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
458 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
460 stubFor(get(urlMatching(".*/service/.*"))
461 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
462 .withBody(mapper.writeValueAsString(defaultService))
463 .withStatus(HttpStatus.SC_OK)));
465 stubFor(get(urlMatching(".*/service/search/.*"))
466 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
467 .withBody(mapper.writeValueAsString(defaultService))
468 .withStatus(HttpStatus.SC_OK)));
470 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
471 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
472 .withBody(mapper.writeValueAsString(serviceRecipe))
473 .withStatus(HttpStatus.SC_OK)));
476 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
477 RequestReferences requestReferences = new RequestReferences();
478 requestReferences.setInstanceId("1882939");
479 expectedResponse.setRequestReferences(requestReferences);
480 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
481 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST);
483 ObjectMapper mapper = new ObjectMapper();
484 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
486 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
487 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
488 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
491 public void deleteServiceInstance() throws IOException {
492 ServiceRecipe serviceRecipe = new ServiceRecipe();
493 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
494 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
495 serviceRecipe.setAction(Action.createInstance.toString());
496 serviceRecipe.setId(1);
497 serviceRecipe.setRecipeTimeout(180);
498 Service defaultService = new Service();
499 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
501 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
502 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
503 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
505 stubFor(get(urlMatching(".*/service/.*"))
506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
507 .withBody(mapper.writeValueAsString(defaultService))
508 .withStatus(HttpStatus.SC_OK)));
510 stubFor(get(urlMatching(".*/service/search/.*"))
511 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
512 .withBody(mapper.writeValueAsString(defaultService))
513 .withStatus(HttpStatus.SC_OK)));
515 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
516 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
517 .withBody(mapper.writeValueAsString(serviceRecipe))
518 .withStatus(HttpStatus.SC_OK)));
520 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
521 RequestReferences requestReferences = new RequestReferences();
522 requestReferences.setInstanceId("1882939");
523 expectedResponse.setRequestReferences(requestReferences);
524 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
525 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE);
527 ObjectMapper mapper = new ObjectMapper();
528 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
530 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
531 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
532 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
535 public void assignServiceInstance() throws IOException {
536 ServiceRecipe serviceRecipe = new ServiceRecipe();
537 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
538 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
539 serviceRecipe.setAction(Action.createInstance.toString());
540 serviceRecipe.setId(1);
541 serviceRecipe.setRecipeTimeout(180);
542 Service defaultService = new Service();
543 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
545 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
546 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
547 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
549 stubFor(get(urlMatching(".*/service/.*"))
550 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
551 .withBody(mapper.writeValueAsString(defaultService))
552 .withStatus(HttpStatus.SC_OK)));
554 stubFor(get(urlMatching(".*/service/search/.*"))
555 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
556 .withBody(mapper.writeValueAsString(defaultService))
557 .withStatus(HttpStatus.SC_OK)));
559 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
560 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
561 .withBody(mapper.writeValueAsString(serviceRecipe))
562 .withStatus(HttpStatus.SC_OK)));
564 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
565 RequestReferences requestReferences = new RequestReferences();
566 requestReferences.setInstanceId("1882939");
567 expectedResponse.setRequestReferences(requestReferences);
568 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
569 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST);
571 ObjectMapper mapper = new ObjectMapper();
572 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
574 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
575 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
576 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
580 public void unassignServiceInstance() throws IOException {
581 ServiceRecipe serviceRecipe = new ServiceRecipe();
582 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
583 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
584 serviceRecipe.setAction(Action.createInstance.toString());
585 serviceRecipe.setId(1);
586 serviceRecipe.setRecipeTimeout(180);
587 Service defaultService = new Service();
588 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
590 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
591 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
592 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
594 stubFor(get(urlMatching(".*/service/.*"))
595 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
596 .withBody(mapper.writeValueAsString(defaultService))
597 .withStatus(HttpStatus.SC_OK)));
599 stubFor(get(urlMatching(".*/service/search/.*"))
600 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
601 .withBody(mapper.writeValueAsString(defaultService))
602 .withStatus(HttpStatus.SC_OK)));
604 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
605 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
606 .withBody(mapper.writeValueAsString(serviceRecipe))
607 .withStatus(HttpStatus.SC_OK)));
609 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
610 RequestReferences requestReferences = new RequestReferences();
611 requestReferences.setInstanceId("1882939");
612 expectedResponse.setRequestReferences(requestReferences);
613 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
614 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST);
616 ObjectMapper mapper = new ObjectMapper();
617 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
619 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
620 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
621 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
624 public void createPortConfiguration() throws IOException {
625 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
626 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
627 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
628 HttpHeaders headers = new HttpHeaders();
629 headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
631 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
632 RequestReferences requestReferences = new RequestReferences();
633 requestReferences.setInstanceId("1882939");
634 expectedResponse.setRequestReferences(requestReferences);
635 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
636 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
638 ObjectMapper mapper = new ObjectMapper();
639 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
641 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
642 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
643 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
644 assertTrue(response.getBody().contains("1882939"));
647 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
648 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
649 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
651 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
654 public void deletePortConfiguration() throws IOException {
655 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
656 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
657 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
659 HttpHeaders headers = new HttpHeaders();
660 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
662 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
663 RequestReferences requestReferences = new RequestReferences();
664 requestReferences.setInstanceId("1882939");
665 expectedResponse.setRequestReferences(requestReferences);
666 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
667 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
669 ObjectMapper mapper = new ObjectMapper();
670 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
672 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
673 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
674 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
677 public void enablePort() throws IOException {
678 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
679 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
680 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
682 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
683 RequestReferences requestReferences = new RequestReferences();
684 requestReferences.setInstanceId("1882939");
685 expectedResponse.setRequestReferences(requestReferences);
686 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
687 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST);
689 ObjectMapper mapper = new ObjectMapper();
690 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
692 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
693 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
694 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
697 public void disablePort() throws IOException {
698 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
699 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
700 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
702 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
703 RequestReferences requestReferences = new RequestReferences();
704 requestReferences.setInstanceId("1882939");
705 expectedResponse.setRequestReferences(requestReferences);
706 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
707 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST);
709 ObjectMapper mapper = new ObjectMapper();
710 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
712 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
713 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
714 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
717 public void activatePort() throws IOException {
718 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
719 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
720 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
722 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
723 RequestReferences requestReferences = new RequestReferences();
724 requestReferences.setInstanceId("1882939");
725 expectedResponse.setRequestReferences(requestReferences);
726 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
727 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST);
729 ObjectMapper mapper = new ObjectMapper();
730 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
732 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
733 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
734 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
737 public void deactivatePort() throws IOException {
738 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
739 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
740 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
742 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
743 RequestReferences requestReferences = new RequestReferences();
744 requestReferences.setInstanceId("1882939");
745 expectedResponse.setRequestReferences(requestReferences);
746 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
747 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST);
749 ObjectMapper mapper = new ObjectMapper();
750 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
752 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
753 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
754 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
757 public void addRelationships() throws IOException {
758 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
759 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
760 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
763 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
764 RequestReferences requestReferences = new RequestReferences();
765 requestReferences.setInstanceId("1882939");
766 expectedResponse.setRequestReferences(requestReferences);
767 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
768 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST);
770 ObjectMapper mapper = new ObjectMapper();
771 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
773 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
774 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
775 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
778 public void removeRelationships() throws IOException {
779 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
780 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
781 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
784 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
785 RequestReferences requestReferences = new RequestReferences();
786 requestReferences.setInstanceId("1882939");
787 expectedResponse.setRequestReferences(requestReferences);
788 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
789 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST);
791 ObjectMapper mapper = new ObjectMapper();
792 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
794 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
795 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
796 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
799 public void createVnfInstanceNoALaCarte() throws IOException {
800 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
801 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
802 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
805 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
806 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
807 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
808 .withStatus(org.apache.http.HttpStatus.SC_OK)));
810 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
811 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
812 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
813 .withStatus(org.apache.http.HttpStatus.SC_OK)));
815 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
816 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
817 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
818 .withStatus(org.apache.http.HttpStatus.SC_OK)));
821 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
822 RequestReferences requestReferences = new RequestReferences();
823 requestReferences.setInstanceId("1882939");
824 expectedResponse.setRequestReferences(requestReferences);
825 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
826 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST);
828 ObjectMapper mapper = new ObjectMapper();
829 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
831 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
832 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
833 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
836 public void createVnfInstance() throws IOException {
837 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
838 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
839 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
841 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
842 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
843 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
844 .withStatus(org.apache.http.HttpStatus.SC_OK)));
845 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
846 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
847 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
848 .withStatus(org.apache.http.HttpStatus.SC_OK)));
851 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
852 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
853 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
854 .withStatus(org.apache.http.HttpStatus.SC_OK)));
856 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
857 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
858 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
859 .withStatus(org.apache.http.HttpStatus.SC_OK)));
861 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3";
862 HttpHeaders headers = new HttpHeaders();
863 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
865 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
866 RequestReferences requestReferences = new RequestReferences();
867 requestReferences.setInstanceId("1882939");
868 expectedResponse.setRequestReferences(requestReferences);
869 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
870 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
872 ObjectMapper mapper = new ObjectMapper();
873 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
875 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
876 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
877 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
878 assertTrue(response.getBody().contains("1882939"));
881 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
882 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
883 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
885 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
888 public void createVnfInstanceInvalidVnfResource() throws IOException {
889 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
890 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
892 ObjectMapper mapper = new ObjectMapper();
893 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
894 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
896 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
897 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
898 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
901 public void replaceVnfInstance() throws IOException {
902 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
903 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
904 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
906 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
907 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
908 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
909 .withStatus(org.apache.http.HttpStatus.SC_OK)));
911 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
912 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
913 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
914 .withStatus(org.apache.http.HttpStatus.SC_OK)));
916 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
917 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
918 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
919 .withStatus(org.apache.http.HttpStatus.SC_OK)));
921 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
922 RequestReferences requestReferences = new RequestReferences();
923 requestReferences.setInstanceId("1882939");
924 expectedResponse.setRequestReferences(requestReferences);
925 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
926 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST);
928 ObjectMapper mapper = new ObjectMapper();
929 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
931 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
932 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
933 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
936 public void replaceVnfRecreateInstance() throws IOException {
937 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
938 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
939 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
941 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
942 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
943 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
944 .withStatus(org.apache.http.HttpStatus.SC_OK)));
946 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
947 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
948 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
949 .withStatus(org.apache.http.HttpStatus.SC_OK)));
951 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
952 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
953 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
954 .withStatus(org.apache.http.HttpStatus.SC_OK)));
957 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
958 RequestReferences requestReferences = new RequestReferences();
959 requestReferences.setInstanceId("1882939");
960 expectedResponse.setRequestReferences(requestReferences);
961 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
962 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST);
963 logger.debug(response.getBody());
964 ObjectMapper mapper = new ObjectMapper();
965 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
967 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
968 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
969 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
972 public void recreateVnfInstance() throws IOException {
973 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
974 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
975 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
977 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
978 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
979 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
980 .withStatus(org.apache.http.HttpStatus.SC_OK)));
982 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
983 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
984 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
985 .withStatus(org.apache.http.HttpStatus.SC_OK)));
987 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
988 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
989 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
990 .withStatus(org.apache.http.HttpStatus.SC_OK)));
993 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
994 RequestReferences requestReferences = new RequestReferences();
995 requestReferences.setInstanceId("1882939");
996 expectedResponse.setRequestReferences(requestReferences);
997 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
998 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST);
999 logger.debug(response.getBody());
1000 ObjectMapper mapper = new ObjectMapper();
1001 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1003 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1004 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1005 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1008 public void updateVnfInstance() throws IOException {
1009 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1010 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1011 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1013 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
1014 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1015 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1016 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1018 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
1019 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1020 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1021 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1023 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1024 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1025 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1026 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1027 .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 + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1035 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT);
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 applyUpdatedConfig() throws IOException {
1046 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1047 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1048 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1051 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1052 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1053 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1054 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1055 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1057 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5";
1058 HttpHeaders headers = new HttpHeaders();
1059 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1061 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1062 RequestReferences requestReferences = new RequestReferences();
1063 requestReferences.setInstanceId("1882939");
1064 expectedResponse.setRequestReferences(requestReferences);
1065 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1066 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1068 ObjectMapper mapper = new ObjectMapper();
1069 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1071 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1072 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1073 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1076 public void deleteVnfInstanceV5() throws IOException {
1077 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1078 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1079 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1081 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1082 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1083 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1084 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1085 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1087 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1088 RequestReferences requestReferences = new RequestReferences();
1089 requestReferences.setInstanceId("1882939");
1090 expectedResponse.setRequestReferences(requestReferences);
1091 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1092 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE);
1094 ObjectMapper mapper = new ObjectMapper();
1095 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1097 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1098 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1099 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1102 public void createVfModuleInstance() throws IOException {
1104 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1105 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1106 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1107 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1109 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1110 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1111 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1112 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1114 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1115 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1116 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1117 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1119 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1120 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1121 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1123 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1124 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1125 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1126 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1127 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1129 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1130 RequestReferences requestReferences = new RequestReferences();
1131 requestReferences.setInstanceId("1882939");
1132 expectedResponse.setRequestReferences(requestReferences);
1133 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1134 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST);
1136 ObjectMapper mapper = new ObjectMapper();
1137 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1139 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1140 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1141 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1142 assertTrue(response.getBody().contains("1882939"));
1145 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1146 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
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/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
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 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1157 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1158 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1159 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1161 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1162 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1163 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1164 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1166 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1167 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1168 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1169 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1170 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1172 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1173 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1174 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1175 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1177 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1178 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1179 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1180 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1183 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1184 "[?]vnfComponentType=vfModule&action=createInstance"))
1185 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1186 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1187 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1190 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1191 RequestReferences requestReferences = new RequestReferences();
1192 requestReferences.setInstanceId("1882939");
1193 expectedResponse.setRequestReferences(requestReferences);
1194 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1195 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST);
1196 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1197 ObjectMapper mapper = new ObjectMapper();
1198 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1199 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1202 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1203 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1204 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1205 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1207 stubFor(get(urlMatching(".*/vnfResource/.*"))
1208 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1209 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1210 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1212 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1213 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1214 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1215 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1217 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1218 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1219 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1220 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1222 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1223 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1224 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1225 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1227 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1228 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1229 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1230 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1232 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1233 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1234 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1235 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1237 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1238 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1239 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1240 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1241 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1244 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1245 RequestReferences requestReferences = new RequestReferences();
1246 requestReferences.setInstanceId("1882939");
1247 expectedResponse.setRequestReferences(requestReferences);
1248 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1249 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE);
1251 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1252 ObjectMapper mapper = new ObjectMapper();
1253 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1254 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1257 public void createVfModuleInstanceNoRecipe() throws IOException {
1259 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1260 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1261 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1262 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1264 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1265 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1266 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1267 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1268 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1270 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1271 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1272 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1273 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1275 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1276 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1277 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1278 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1279 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1281 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1282 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST);
1284 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1285 ObjectMapper mapper = new ObjectMapper();
1286 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
1287 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
1288 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1291 public void replaceVfModuleInstance() throws IOException {
1292 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1293 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1294 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1296 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1297 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1298 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1299 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1300 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1302 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1303 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1304 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1305 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1306 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1308 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1309 RequestReferences requestReferences = new RequestReferences();
1310 requestReferences.setInstanceId("1882939");
1311 expectedResponse.setRequestReferences(requestReferences);
1312 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1313 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST);
1315 ObjectMapper mapper = new ObjectMapper();
1316 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1318 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1319 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1320 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1323 public void updateVfModuleInstance() throws IOException {
1324 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1325 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1326 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1328 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1329 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1330 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1331 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1333 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1334 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1335 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1336 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1338 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1339 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1340 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1341 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1343 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1344 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1345 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1346 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1347 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1350 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1351 RequestReferences requestReferences = new RequestReferences();
1352 requestReferences.setInstanceId("1882939");
1353 expectedResponse.setRequestReferences(requestReferences);
1354 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1355 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT);
1356 logger.debug(response.getBody());
1358 ObjectMapper mapper = new ObjectMapper();
1359 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1361 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1362 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1363 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1366 public void createVfModuleNoModelType() throws IOException{
1367 HttpHeaders headers = new HttpHeaders();
1368 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1369 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1370 expectedRecord.setRequestStatus("FAILED");
1371 expectedRecord.setAction("createInstance");
1372 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1373 expectedRecord.setProgress(100L);
1374 expectedRecord.setSource("VID");
1375 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1376 expectedRecord.setLastModifiedBy("APIH");
1377 expectedRecord.setVfModuleName("testVfModule2");
1378 expectedRecord.setVfModuleModelName("serviceModel");
1379 expectedRecord.setRequestScope("vfModule");
1380 expectedRecord.setRequestAction("createInstance");
1381 expectedRecord.setRequestorId("zz9999");
1382 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1383 //VnfType is not sent in this request, should be blank in db
1384 expectedRecord.setVnfType("");
1385 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1387 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1389 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1392 public void inPlaceSoftwareUpdate() throws IOException {
1393 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1394 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1395 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1397 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1398 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1399 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1400 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1401 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1404 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1405 RequestReferences requestReferences = new RequestReferences();
1406 requestReferences.setInstanceId("1882939");
1407 expectedResponse.setRequestReferences(requestReferences);
1408 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate";
1409 ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST);
1411 ObjectMapper mapper = new ObjectMapper();
1412 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1414 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1415 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1416 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1420 public void deleteVfModuleInstance() throws IOException {
1421 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1422 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1423 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1425 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1426 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1427 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1428 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1429 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1431 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1432 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1433 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1434 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1435 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1438 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1439 RequestReferences requestReferences = new RequestReferences();
1440 requestReferences.setInstanceId("1882939");
1441 expectedResponse.setRequestReferences(requestReferences);
1442 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1443 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE);
1445 ObjectMapper mapper = new ObjectMapper();
1446 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1448 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1449 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1450 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1453 public void deleteVfModuleNoModelInvariantId() throws IOException {
1454 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1455 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1456 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1458 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1459 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1460 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1461 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1462 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1465 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1466 RequestReferences requestReferences = new RequestReferences();
1467 requestReferences.setInstanceId("1882939");
1468 expectedResponse.setRequestReferences(requestReferences);
1469 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1470 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE);
1472 ObjectMapper mapper = new ObjectMapper();
1473 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1475 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1476 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1477 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1480 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1481 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1482 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1483 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1485 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1486 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1487 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1488 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1489 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1491 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1492 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1493 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1494 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1495 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1498 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1499 RequestReferences requestReferences = new RequestReferences();
1500 requestReferences.setInstanceId("1882939");
1501 expectedResponse.setRequestReferences(requestReferences);
1502 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1503 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST);
1505 ObjectMapper mapper = new ObjectMapper();
1506 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1508 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1509 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1510 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1513 public void createVolumeGroupInstance() throws IOException {
1514 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1515 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1516 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1518 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1519 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1520 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1521 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1523 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1524 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1525 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1526 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1528 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1529 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1530 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1531 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1532 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1535 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1536 RequestReferences requestReferences = new RequestReferences();
1537 requestReferences.setInstanceId("1882939");
1538 expectedResponse.setRequestReferences(requestReferences);
1539 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1540 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST);
1542 ObjectMapper mapper = new ObjectMapper();
1543 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1545 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1546 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1547 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1548 assertTrue(response.getBody().contains("1882939"));
1551 public void updateVolumeGroupInstance() throws IOException {
1552 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1553 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1554 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1556 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1557 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1558 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1559 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1561 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1562 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1563 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1564 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1566 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1567 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1568 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1569 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1570 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1573 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1574 RequestReferences requestReferences = new RequestReferences();
1575 requestReferences.setInstanceId("1882939");
1576 expectedResponse.setRequestReferences(requestReferences);
1577 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1578 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT);
1580 ObjectMapper mapper = new ObjectMapper();
1581 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1583 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1584 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1585 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1588 public void deleteVolumeGroupInstance() throws IOException {
1589 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1590 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1591 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1593 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1594 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1595 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1597 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1598 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1599 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1600 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1602 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1604 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1605 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1607 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1608 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1609 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1610 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1611 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1614 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1615 RequestReferences requestReferences = new RequestReferences();
1616 requestReferences.setInstanceId("1882939");
1617 expectedResponse.setRequestReferences(requestReferences);
1618 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1619 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE);
1621 ObjectMapper mapper = new ObjectMapper();
1622 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1624 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1625 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1626 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1629 public void createNetworkInstance() throws IOException {
1630 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1631 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1632 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1634 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1635 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1636 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1637 .withStatus(HttpStatus.SC_OK)));
1639 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1640 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1641 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1642 .withStatus(HttpStatus.SC_OK)));
1644 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1645 "modelName=GR-API-DEFAULT&action=createInstance"))
1646 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1647 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1648 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1650 String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4";
1651 HttpHeaders headers = new HttpHeaders();
1652 headers.set(MsoLogger.ONAP_REQUEST_ID, requestId);
1654 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1655 RequestReferences requestReferences = new RequestReferences();
1656 requestReferences.setInstanceId("1882939");
1657 expectedResponse.setRequestReferences(requestReferences);
1658 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1659 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1661 ObjectMapper mapper = new ObjectMapper();
1662 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1664 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1665 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1666 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1669 public void updateNetworkInstance() throws IOException {
1670 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1671 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1672 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1674 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1675 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1676 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1677 .withStatus(HttpStatus.SC_OK)));
1679 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1680 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1681 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1682 .withStatus(HttpStatus.SC_OK)));
1684 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1685 "modelName=GR-API-DEFAULT&action=updateInstance"))
1686 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1687 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1688 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1690 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1691 RequestReferences requestReferences = new RequestReferences();
1692 requestReferences.setInstanceId("1882939");
1693 expectedResponse.setRequestReferences(requestReferences);
1694 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1695 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT);
1697 ObjectMapper mapper = new ObjectMapper();
1698 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1700 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1701 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1702 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1703 assertTrue(response.getBody().contains("1882939"));
1706 public void deleteNetworkInstance() throws IOException {
1707 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1708 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1709 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1711 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1712 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1713 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1714 .withStatus(HttpStatus.SC_OK)));
1716 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1717 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1718 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1719 .withStatus(HttpStatus.SC_OK)));
1721 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1722 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1723 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1724 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1725 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1728 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1729 RequestReferences requestReferences = new RequestReferences();
1730 requestReferences.setInstanceId("1882939");
1731 expectedResponse.setRequestReferences(requestReferences);
1732 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1733 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE);
1735 ObjectMapper mapper = new ObjectMapper();
1736 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1738 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1739 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1740 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1743 public void deleteNetworkInstanceNoReqParams() throws IOException {
1744 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1745 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1746 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1748 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1749 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1750 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1751 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1752 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1756 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1757 RequestReferences requestReferences = new RequestReferences();
1758 requestReferences.setInstanceId("1882939");
1759 expectedResponse.setRequestReferences(requestReferences);
1760 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1761 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE);
1763 ObjectMapper mapper = new ObjectMapper();
1764 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1766 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1767 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1768 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1771 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1772 HttpHeaders headers = new HttpHeaders();
1773 headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
1775 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1776 expectedRecord.setRequestStatus("FAILED");
1777 expectedRecord.setStatusMessage("Error mapping request: ");
1778 expectedRecord.setProgress(100L);
1779 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1780 expectedRecord.setLastModifiedBy("APIH");
1781 expectedRecord.setRequestScope("network");
1782 expectedRecord.setRequestAction("deleteInstance");
1783 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1785 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1786 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1790 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1793 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1794 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1795 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1797 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1801 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1802 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1803 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1804 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1806 ServiceRecipe serviceRecipe = new ServiceRecipe();
1807 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1808 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1809 serviceRecipe.setAction(Action.createInstance.toString());
1810 serviceRecipe.setId(1);
1811 serviceRecipe.setRecipeTimeout(180);
1812 Service defaultService = new Service();
1813 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1815 stubFor(get(urlMatching(".*/service/.*"))
1816 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1817 .withBody(mapper.writeValueAsString(defaultService))
1818 .withStatus(HttpStatus.SC_OK)));
1820 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1821 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1822 .withBody(mapper.writeValueAsString(serviceRecipe))
1823 .withStatus(HttpStatus.SC_OK)));
1825 uri = servInstanceuri + "v7" + "/serviceInstances";
1826 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST);
1829 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1830 RequestReferences requestReferences = new RequestReferences();
1831 requestReferences.setInstanceId("1882939");
1832 expectedResponse.setRequestReferences(requestReferences);
1834 ObjectMapper mapper = new ObjectMapper();
1835 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1837 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1838 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1839 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1843 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1844 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1845 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1846 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1848 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1849 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1850 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1851 .withStatus(HttpStatus.SC_OK)));
1853 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1854 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1855 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1856 .withStatus(HttpStatus.SC_OK)));
1858 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1859 "modelName=GR-API-DEFAULT&action=createInstance"))
1860 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1861 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1862 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1864 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1865 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST);
1868 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1869 RequestReferences requestReferences = new RequestReferences();
1870 requestReferences.setInstanceId("1882939");
1871 expectedResponse.setRequestReferences(requestReferences);
1873 ObjectMapper mapper = new ObjectMapper();
1874 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1876 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1877 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1878 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1882 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1883 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1884 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1885 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1887 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1888 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1891 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1892 RequestReferences requestReferences = new RequestReferences();
1893 requestReferences.setInstanceId("1882939");
1894 expectedResponse.setRequestReferences(requestReferences);
1896 ObjectMapper mapper = new ObjectMapper();
1897 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1899 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1903 public void createNetworkInstanceTestApiGrApi() throws IOException {
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)));
1908 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1909 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1910 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1911 .withStatus(HttpStatus.SC_OK)));
1913 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1914 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1915 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1916 .withStatus(HttpStatus.SC_OK)));
1918 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1919 "modelName=GR-API-DEFAULT&action=createInstance"))
1920 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1921 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1922 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1924 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1925 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST);
1928 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1929 RequestReferences requestReferences = new RequestReferences();
1930 requestReferences.setInstanceId("1882939");
1931 expectedResponse.setRequestReferences(requestReferences);
1933 ObjectMapper mapper = new ObjectMapper();
1934 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1936 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1937 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1938 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1942 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1943 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1944 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1945 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1947 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1948 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1949 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1950 .withStatus(HttpStatus.SC_OK)));
1952 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1953 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1954 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1955 .withStatus(HttpStatus.SC_OK)));
1957 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1958 "modelName=VNF-API-DEFAULT&action=createInstance"))
1959 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1960 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1961 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1963 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1964 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST);
1967 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1968 RequestReferences requestReferences = new RequestReferences();
1969 requestReferences.setInstanceId("1882939");
1970 expectedResponse.setRequestReferences(requestReferences);
1972 ObjectMapper mapper = new ObjectMapper();
1973 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
1975 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1976 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1977 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1981 public void activateServiceInstanceRequestStatus() throws IOException{
1982 ServiceRecipe serviceRecipe = new ServiceRecipe();
1983 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1984 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1985 serviceRecipe.setAction(Action.createInstance.toString());
1986 serviceRecipe.setId(1);
1987 serviceRecipe.setRecipeTimeout(180);
1988 Service defaultService = new Service();
1989 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1991 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1992 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1993 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1994 HttpHeaders headers = new HttpHeaders();
1995 headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d");
1997 stubFor(get(urlMatching(".*/service/.*"))
1998 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1999 .withBody(mapper.writeValueAsString(defaultService))
2000 .withStatus(HttpStatus.SC_OK)));
2002 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2003 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2004 .withBody(mapper.writeValueAsString(serviceRecipe))
2005 .withStatus(HttpStatus.SC_OK)));
2008 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2009 RequestReferences requestReferences = new RequestReferences();
2010 requestReferences.setInstanceId("1882939");
2011 expectedResponse.setRequestReferences(requestReferences);
2012 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
2013 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
2015 ObjectMapper mapper = new ObjectMapper();
2016 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2018 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2019 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2020 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2024 public void invalidRequestId() throws IOException {
2025 String illegalRequestId = "1234";
2026 HttpHeaders headers = new HttpHeaders();
2027 headers.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
2029 uri = servInstanceuri + "v5/serviceInstances";
2030 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2032 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2033 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
2036 public void invalidBPELResponse() throws IOException{
2038 ServiceRecipe serviceRecipe = new ServiceRecipe();
2039 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2040 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2041 serviceRecipe.setAction(Action.createInstance.toString());
2042 serviceRecipe.setId(1);
2043 serviceRecipe.setRecipeTimeout(180);
2044 Service defaultService = new Service();
2045 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2047 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2048 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2049 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2051 stubFor(get(urlMatching(".*/service/.*"))
2052 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2053 .withBody(mapper.writeValueAsString(defaultService))
2054 .withStatus(HttpStatus.SC_OK)));
2056 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2057 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2058 .withBody(mapper.writeValueAsString(serviceRecipe))
2059 .withStatus(HttpStatus.SC_OK)));
2061 uri = servInstanceuri + "v5/serviceInstances";
2062 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2064 ObjectMapper mapper = new ObjectMapper();
2065 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2066 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2068 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2069 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2070 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
2073 public void unauthorizedBPELResponse() throws IOException{
2075 ServiceRecipe serviceRecipe = new ServiceRecipe();
2076 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2077 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2078 serviceRecipe.setAction(Action.createInstance.toString());
2079 serviceRecipe.setId(1);
2080 serviceRecipe.setRecipeTimeout(180);
2081 Service defaultService = new Service();
2082 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2084 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2085 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2086 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2088 stubFor(get(urlMatching(".*/service/.*"))
2089 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2090 .withBody(mapper.writeValueAsString(defaultService))
2091 .withStatus(HttpStatus.SC_OK)));
2093 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2094 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2095 .withBody(mapper.writeValueAsString(serviceRecipe))
2096 .withStatus(HttpStatus.SC_OK)));
2098 uri = servInstanceuri + "v5/serviceInstances";
2099 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2101 ObjectMapper mapper = new ObjectMapper();
2102 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2103 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2105 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2106 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2107 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2111 public void invalidBPELResponse2() throws IOException{
2113 ServiceRecipe serviceRecipe = new ServiceRecipe();
2114 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2115 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2116 serviceRecipe.setAction(Action.createInstance.toString());
2117 serviceRecipe.setId(1);
2118 serviceRecipe.setRecipeTimeout(180);
2119 Service defaultService = new Service();
2120 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2122 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2123 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2124 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2126 stubFor(get(urlMatching(".*/service/.*"))
2127 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2128 .withBody(mapper.writeValueAsString(defaultService))
2129 .withStatus(HttpStatus.SC_OK)));
2131 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2132 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2133 .withBody(mapper.writeValueAsString(serviceRecipe))
2134 .withStatus(HttpStatus.SC_OK)));
2135 uri = servInstanceuri + "v5/serviceInstances";
2136 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2138 ObjectMapper mapper = new ObjectMapper();
2139 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2140 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2142 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2143 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2144 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2148 public void createMacroServiceInstance() throws IOException{
2149 ServiceRecipe serviceRecipe = new ServiceRecipe();
2150 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2151 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2152 serviceRecipe.setAction(Action.createInstance.toString());
2153 serviceRecipe.setId(1);
2154 serviceRecipe.setRecipeTimeout(180);
2155 Service defaultService = new Service();
2156 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2158 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2159 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2160 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2162 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2163 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2164 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2166 stubFor(get(urlMatching(".*/service/.*"))
2167 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2168 .withBody(mapper.writeValueAsString(defaultService))
2169 .withStatus(HttpStatus.SC_OK)));
2171 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2172 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2173 .withBody(mapper.writeValueAsString(serviceRecipe))
2174 .withStatus(HttpStatus.SC_OK)));
2177 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2178 RequestReferences requestReferences = new RequestReferences();
2179 requestReferences.setInstanceId("1882939");
2180 expectedResponse.setRequestReferences(requestReferences);
2181 uri = servInstanceUriPrev7 + "v5";
2182 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST);
2184 ObjectMapper mapper = new ObjectMapper();
2185 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2188 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2189 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2190 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2194 public void testUserParams() throws IOException {
2195 ObjectMapper mapper = new ObjectMapper();
2196 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2197 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2198 String userParamsTxt = inputStream("/userParams.txt");
2200 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2201 System.out.println(userParams);
2202 assertTrue(userParams.size() > 0);
2203 assertTrue(userParams.get(0).containsKey("name"));
2204 assertTrue(userParams.get(0).containsKey("value"));
2205 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2209 public void testConfigureCloudConfig() throws IOException {
2210 ObjectMapper mapper = new ObjectMapper();
2211 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2212 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2214 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2215 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2219 public void testMapToLegacyRequest() throws IOException {
2220 ObjectMapper mapper = new ObjectMapper();
2221 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2222 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2223 servInstances.mapToLegacyRequest(request.getRequestDetails());
2224 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2225 assertThat(request, sameBeanAs(expected));
2228 public void scaleOutVfModule() throws IOException {
2229 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2230 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2231 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2233 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2234 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2235 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2236 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2238 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2239 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2240 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2241 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2243 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2244 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2245 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2246 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2249 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2250 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2251 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2252 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2254 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2255 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2256 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2259 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2260 RequestReferences requestReferences = new RequestReferences();
2261 requestReferences.setInstanceId("1882939");
2262 expectedResponse.setRequestReferences(requestReferences);
2263 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2264 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST);
2266 ObjectMapper mapper = new ObjectMapper();
2267 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2269 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2270 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2271 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2272 assertTrue(response.getBody().contains("1882939"));
2275 public void createServiceInstanceBadResponse() throws IOException{
2276 ServiceRecipe serviceRecipe = new ServiceRecipe();
2277 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2278 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2279 serviceRecipe.setAction(Action.createInstance.toString());
2280 serviceRecipe.setId(1);
2281 serviceRecipe.setRecipeTimeout(180);
2282 Service defaultService = new Service();
2283 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2285 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2286 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2287 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2289 stubFor(get(urlMatching(".*/service/.*"))
2290 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2291 .withBody(mapper.writeValueAsString(defaultService))
2292 .withStatus(HttpStatus.SC_OK)));
2294 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2295 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2296 .withBody(mapper.writeValueAsString(serviceRecipe))
2297 .withStatus(HttpStatus.SC_OK)));
2299 uri = servInstanceuri + "v5/serviceInstances";
2300 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2302 ObjectMapper mapper = new ObjectMapper();
2303 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2304 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2306 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2307 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2308 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2311 public void createServiceInstanceDuplicateError() throws IOException{
2312 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2313 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2314 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2316 uri = servInstanceuri + "v5/serviceInstances";
2317 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2319 ObjectMapper mapper = new ObjectMapper();
2320 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2321 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2323 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2324 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2325 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2328 public void createServiceInstanceSaveError() throws IOException{
2329 ServiceRecipe serviceRecipe = new ServiceRecipe();
2330 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2331 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2332 serviceRecipe.setAction(Action.createInstance.toString());
2333 serviceRecipe.setId(1);
2334 serviceRecipe.setRecipeTimeout(180);
2335 Service defaultService = new Service();
2336 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2337 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2338 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2339 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2340 stubFor(get(urlMatching(".*/service/.*"))
2341 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2342 .withBody(mapper.writeValueAsString(defaultService))
2343 .withStatus(HttpStatus.SC_OK)));
2345 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2346 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2347 .withBody(mapper.writeValueAsString(serviceRecipe))
2348 .withStatus(HttpStatus.SC_OK)));
2350 uri = servInstanceuri + "v5/serviceInstances";
2351 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST);
2353 ObjectMapper mapper = new ObjectMapper();
2354 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2355 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2357 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2358 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2359 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2362 public void createPortConfigurationSaveError() throws IOException {
2363 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2364 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2365 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2366 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2367 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2368 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2370 HttpHeaders headers = new HttpHeaders();
2372 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2373 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2375 ObjectMapper mapper = new ObjectMapper();
2376 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2377 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2379 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2380 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2381 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2384 public void createPortConfigDbUpdateError() throws IOException {
2385 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2386 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2387 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2389 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2390 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
2392 ObjectMapper mapper = new ObjectMapper();
2393 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2394 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2396 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2397 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2398 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2401 public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
2402 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2403 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2404 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2406 stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2407 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2408 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2409 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2411 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
2412 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2413 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2414 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2416 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
2417 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2418 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2419 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2420 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2421 HttpHeaders headers = new HttpHeaders();
2422 headers.set(MsoLogger.CLIENT_ID, "VID");
2424 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2425 RequestReferences requestReferences = new RequestReferences();
2426 requestReferences.setInstanceId("1882939");
2427 expectedResponse.setRequestReferences(requestReferences);
2428 uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2429 ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2431 ObjectMapper mapper = new ObjectMapper();
2432 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2435 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2436 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2437 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2440 public void createInstanceGroup() throws IOException{
2441 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2442 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2443 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2445 HttpHeaders headers = new HttpHeaders();
2447 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2448 RequestReferences requestReferences = new RequestReferences();
2449 requestReferences.setInstanceId("1882939");
2450 expectedResponse.setRequestReferences(requestReferences);
2451 uri = servInstanceuri + "/v7/instanceGroups";
2452 ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2454 ObjectMapper mapper = new ObjectMapper();
2455 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2458 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2459 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2460 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2463 public void deleteInstanceGroup() throws IOException{
2464 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2465 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2466 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2468 HttpHeaders headers = new HttpHeaders();
2469 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2470 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
2471 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
2473 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2474 RequestReferences requestReferences = new RequestReferences();
2475 requestReferences.setInstanceId("1882939");
2476 expectedResponse.setRequestReferences(requestReferences);
2477 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2478 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2480 ObjectMapper mapper = new ObjectMapper();
2481 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2484 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2485 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2486 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2489 public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
2490 HttpHeaders headers = new HttpHeaders();
2491 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
2492 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
2493 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2494 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2496 ObjectMapper mapper = new ObjectMapper();
2497 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2498 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2501 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2502 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2503 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2506 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
2507 HttpHeaders headers = new HttpHeaders();
2508 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2509 headers.set(MsoLogger.REQUESTOR_ID, "xxxxxx");
2510 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2511 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2513 ObjectMapper mapper = new ObjectMapper();
2514 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2515 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2518 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2519 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2520 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2523 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException{
2524 HttpHeaders headers = new HttpHeaders();
2525 headers.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2526 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2528 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2529 RequestReferences requestReferences = new RequestReferences();
2530 requestReferences.setInstanceId("1882939");
2531 expectedResponse.setRequestReferences(requestReferences);
2532 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2533 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2535 ObjectMapper mapper = new ObjectMapper();
2536 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2537 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
2540 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2541 RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
2542 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2545 public void addMembers() throws IOException{
2546 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2547 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2548 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2549 HttpHeaders headers = new HttpHeaders();
2551 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2552 RequestReferences requestReferences = new RequestReferences();
2553 requestReferences.setInstanceId("1882939");
2554 expectedResponse.setRequestReferences(requestReferences);
2555 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2556 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2558 ObjectMapper mapper = new ObjectMapper();
2559 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2562 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2563 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2564 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2567 public void removeMembers() throws IOException{
2568 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2569 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2570 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2571 HttpHeaders headers = new HttpHeaders();
2573 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2574 RequestReferences requestReferences = new RequestReferences();
2575 requestReferences.setInstanceId("1882939");
2576 expectedResponse.setRequestReferences(requestReferences);
2577 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2578 ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2580 ObjectMapper mapper = new ObjectMapper();
2581 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2584 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2585 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2586 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2589 public void setServiceTypeTestALaCarte() throws JsonProcessingException{
2590 String requestScope = ModelType.service.toString();
2591 Boolean aLaCarteFlag = true;
2592 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2593 RequestDetails requestDetails = new RequestDetails();
2594 RequestInfo requestInfo = new RequestInfo();
2595 requestInfo.setSource("VID");
2596 requestDetails.setRequestInfo(requestInfo);
2597 sir.setRequestDetails(requestDetails);
2598 Service defaultService = new Service();
2599 defaultService.setServiceType("testServiceTypeALaCarte");
2601 stubFor(get(urlMatching(".*/service/search/.*"))
2602 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2603 .withBody(mapper.writeValueAsString(defaultService))
2604 .withStatus(HttpStatus.SC_OK)));
2606 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2607 assertEquals(serviceType, "testServiceTypeALaCarte");
2610 public void setServiceTypeTest() throws JsonProcessingException{
2611 String requestScope = ModelType.service.toString();
2612 Boolean aLaCarteFlag = false;
2613 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2614 RequestDetails requestDetails = new RequestDetails();
2615 RequestInfo requestInfo = new RequestInfo();
2616 ModelInfo modelInfo = new ModelInfo();
2617 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2618 requestInfo.setSource("VID");
2619 requestDetails.setModelInfo(modelInfo);
2620 requestDetails.setRequestInfo(requestInfo);
2621 sir.setRequestDetails(requestDetails);
2622 Service defaultService = new Service();
2623 defaultService.setServiceType("testServiceType");
2625 stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2626 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2627 .withBody(mapper.writeValueAsString(defaultService))
2628 .withStatus(HttpStatus.SC_OK)));
2630 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2631 assertEquals(serviceType, "testServiceType");
2634 public void setServiceTypeTestDefault() throws JsonProcessingException{
2635 String requestScope = ModelType.service.toString();
2636 Boolean aLaCarteFlag = false;
2637 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2638 RequestDetails requestDetails = new RequestDetails();
2639 RequestInfo requestInfo = new RequestInfo();
2640 ModelInfo modelInfo = new ModelInfo();
2641 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2642 requestInfo.setSource("VID");
2643 requestDetails.setModelInfo(modelInfo);
2644 requestDetails.setRequestInfo(requestInfo);
2645 sir.setRequestDetails(requestDetails);
2646 Service defaultService = new Service();
2647 defaultService.setServiceType("testServiceType");
2649 stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2650 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2651 .withStatus(HttpStatus.SC_NOT_FOUND)));
2652 stubFor(get(urlMatching(".*/service/search/.*"))
2653 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2654 .withBody(mapper.writeValueAsString(defaultService))
2655 .withStatus(HttpStatus.SC_OK)));
2657 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2658 assertEquals(serviceType, "testServiceType");
2661 public void setServiceTypeTestNetwork() throws JsonProcessingException{
2662 String requestScope = ModelType.network.toString();
2663 Boolean aLaCarteFlag = null;
2664 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2665 RequestDetails requestDetails = new RequestDetails();
2666 RequestInfo requestInfo = new RequestInfo();
2667 ModelInfo modelInfo = new ModelInfo();
2668 modelInfo.setModelName("networkModelName");
2669 requestInfo.setSource("VID");
2670 requestDetails.setModelInfo(modelInfo);
2671 requestDetails.setRequestInfo(requestInfo);
2672 sir.setRequestDetails(requestDetails);
2674 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2675 assertEquals(serviceType, "networkModelName");