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.assertFalse;
33 import static org.junit.Assert.assertNotNull;
34 import static org.junit.Assert.assertNull;
35 import static org.junit.Assert.assertThat;
36 import static org.junit.Assert.assertTrue;
37 import static org.onap.so.logger.HttpHeadersConstants.ONAP_REQUEST_ID;
38 import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID;
39 import static org.onap.so.logger.MdcConstants.CLIENT_ID;
40 import static org.onap.so.logger.MdcConstants.ENDTIME;
41 import static org.onap.so.logger.MdcConstants.INVOCATION_ID;
42 import static org.onap.so.logger.MdcConstants.PARTNERNAME;
43 import static org.onap.so.logger.MdcConstants.RESPONSECODE;
44 import static org.onap.so.logger.MdcConstants.RESPONSEDESC;
45 import static org.onap.so.logger.MdcConstants.SERVICE_NAME;
46 import static org.onap.so.logger.MdcConstants.STATUSCODE;
47 import static org.onap.so.logger.HttpHeadersConstants.TRANSACTION_ID;
51 import java.io.IOException;
52 import java.net.MalformedURLException;
54 import java.net.URISyntaxException;
56 import java.nio.file.Files;
57 import java.nio.file.Paths;
58 import java.util.List;
61 import javax.ws.rs.core.MediaType;
62 import javax.ws.rs.core.Response;
64 import org.apache.http.HttpStatus;
65 import org.junit.Before;
66 import org.junit.Ignore;
67 import org.junit.Test;
68 import org.onap.logging.ref.slf4j.ONAPLogConstants;
69 import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
70 import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
71 import org.onap.so.db.catalog.beans.Service;
72 import org.onap.so.db.catalog.beans.ServiceRecipe;
73 import org.onap.so.db.request.beans.InfraActiveRequests;
74 import org.onap.so.logger.HttpHeadersConstants;
75 import org.onap.so.serviceinstancebeans.CloudConfiguration;
76 import org.onap.so.serviceinstancebeans.ModelInfo;
77 import org.onap.so.serviceinstancebeans.RequestDetails;
78 import org.onap.so.serviceinstancebeans.RequestError;
79 import org.onap.so.serviceinstancebeans.RequestInfo;
80 import org.onap.so.serviceinstancebeans.RequestParameters;
81 import org.onap.so.serviceinstancebeans.RequestReferences;
82 import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
83 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
84 import org.springframework.beans.factory.annotation.Autowired;
85 import org.springframework.beans.factory.annotation.Value;
86 import org.springframework.http.HttpEntity;
87 import org.springframework.http.HttpHeaders;
88 import org.springframework.http.HttpMethod;
89 import org.springframework.http.ResponseEntity;
90 import org.springframework.util.ResourceUtils;
91 import org.springframework.web.util.UriComponentsBuilder;
93 import com.fasterxml.jackson.annotation.JsonInclude.Include;
94 import com.fasterxml.jackson.core.JsonParseException;
95 import com.fasterxml.jackson.core.JsonProcessingException;
96 import com.fasterxml.jackson.databind.DeserializationFeature;
97 import com.fasterxml.jackson.databind.JsonMappingException;
98 import com.fasterxml.jackson.databind.ObjectMapper;
99 import com.github.tomakehurst.wiremock.http.Fault;
101 import ch.qos.logback.classic.spi.ILoggingEvent;
104 public class ServiceInstancesTest extends BaseTest{
106 private final ObjectMapper mapper = new ObjectMapper();
107 private ObjectMapper errorMapper = new ObjectMapper();
110 private ServiceInstances servInstances;
112 @Value("${wiremock.server.port}")
113 private String wiremockPort;
115 private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/";
116 private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/";
118 private URL selfLink;
119 private URL initialUrl;
120 private int initialPort;
121 private HttpHeaders headers;
124 public void beforeClass() {
125 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
126 errorMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
127 errorMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
129 headers = new HttpHeaders();
130 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "test_name");
131 headers.set(HttpHeadersConstants.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
132 headers.set(ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
133 headers.set(ONAPLogConstants.MDCs.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
134 headers.set(CLIENT_ID, "VID");
135 headers.set(REQUESTOR_ID, "xxxxxx");
136 try { // generate one-time port number to avoid RANDOM port number later.
137 initialUrl = new URL(createURLWithPort(Constants.ORCHESTRATION_REQUESTS_PATH));
138 initialPort = initialUrl.getPort();
139 } catch (MalformedURLException e) {
142 stubFor(post(urlMatching(".*/infraActiveRequests.*"))
143 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
144 .withStatus(HttpStatus.SC_OK)));
147 public String inputStream(String JsonInput)throws IOException{
148 JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput;
149 return new String(Files.readAllBytes(Paths.get(JsonInput)));
152 private URL createExpectedSelfLink(String version, String requestId) {
153 System.out.println("createdUrl: " + initialUrl.toString());
155 selfLink = new URL(initialUrl.toString().concat("/").concat(version).concat("/").concat(requestId));
156 } catch (MalformedURLException e) {
162 private String getWiremockResponseForCatalogdb(String file) {
164 File resource= ResourceUtils.getFile("classpath:__files/catalogdb/"+file);
165 return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090","localhost:"+wiremockPort);
166 } catch (IOException e) {
173 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod, HttpHeaders headers){
175 if (!headers.containsKey(HttpHeaders.ACCEPT)) {
176 headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
178 if (!headers.containsKey(HttpHeaders.CONTENT_TYPE)) {
179 headers.set(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON);
182 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath, initialPort));
184 HttpEntity<String> request = new HttpEntity<>(requestJson, headers);
186 return restTemplate.exchange(builder.toUriString(),
187 reqMethod, request, String.class);
190 public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){
191 return sendRequest(requestJson, uriPath, reqMethod, new HttpHeaders());
195 public void test_mapJSONtoMSOStyle() throws IOException{
196 ObjectMapper mapper = new ObjectMapper();
197 mapper.setSerializationInclusion(Include.NON_NULL);
198 String testRequest= inputStream("/ServiceInstanceDefault.json");
199 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null);
200 ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class);
201 ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
202 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid());
203 assertEquals("modelInstanceName",modelInfo.getModelInstanceName());
204 assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid());
205 assertEquals("10",modelInfo.getModelUuid());
211 public void test_mapJSONtoMSOStyleUsePreload() throws IOException{
212 ObjectMapper mapper = new ObjectMapper();
213 mapper.setSerializationInclusion(Include.NON_NULL);
214 String testRequest= inputStream("/ServiceInstanceDefault.json");
215 ServiceInstancesRequest sir = new ServiceInstancesRequest();
216 RequestDetails rd = new RequestDetails();
217 RequestParameters rp = new RequestParameters();
218 rp.setUsePreload(true);
219 rd.setRequestParameters(rp);
220 sir.setRequestDetails(rd);
221 String resultString = servInstances.mapJSONtoMSOStyle(testRequest, sir, false, null);
222 ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class);
223 assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload());
227 public void createServiceInstanceVIDDefault() throws IOException{
228 TestAppender.events.clear();
230 ServiceRecipe serviceRecipe = new ServiceRecipe();
231 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
232 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
233 serviceRecipe.setAction(Action.createInstance.toString());
234 serviceRecipe.setId(1);
235 serviceRecipe.setRecipeTimeout(180);
236 Service defaultService = new Service();
237 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
240 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
241 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
242 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
244 stubFor(get(urlMatching(".*/service/search/.*"))
245 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
246 .withBody(mapper.writeValueAsString(defaultService))
247 .withStatus(HttpStatus.SC_OK)));
249 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
250 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
251 .withBody(mapper.writeValueAsString(serviceRecipe))
252 .withStatus(HttpStatus.SC_OK)));
255 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
256 RequestReferences requestReferences = new RequestReferences();
257 requestReferences.setInstanceId("1882939");
258 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
259 expectedResponse.setRequestReferences(requestReferences);
260 uri = servInstanceuri + "v5/serviceInstances";
261 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
264 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
265 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
266 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
270 for(ILoggingEvent logEvent : TestAppender.events)
271 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
272 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
274 Map<String,String> mdc = logEvent.getMDCPropertyMap();
275 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
276 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
277 assertNotNull(mdc.get(INVOCATION_ID));
278 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
279 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(SERVICE_NAME));
280 assertEquals("INPROGRESS",mdc.get(STATUSCODE));
281 }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
282 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
283 Map<String,String> mdc = logEvent.getMDCPropertyMap();
284 assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
285 assertNotNull(mdc.get(ENDTIME));
286 assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
287 assertNotNull(mdc.get(INVOCATION_ID));
288 assertEquals("202",mdc.get(RESPONSECODE));
289 assertEquals("UNKNOWN",mdc.get(PARTNERNAME));
290 assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(SERVICE_NAME));
291 assertEquals("COMPLETE",mdc.get(STATUSCODE));
292 assertNotNull(mdc.get(RESPONSEDESC));
293 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
294 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
295 assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0));
299 public void createServiceInstanceServiceInstancesUri() throws IOException{
300 ServiceRecipe serviceRecipe = new ServiceRecipe();
301 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateGenericALaCarteServiceInstance");
302 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
303 serviceRecipe.setAction(Action.createInstance.toString());
304 serviceRecipe.setId(1);
305 serviceRecipe.setRecipeTimeout(180);
306 Service defaultService = new Service();
307 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
309 stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance"))
310 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
311 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
314 stubFor(get(urlMatching(".*/service/search/.*"))
315 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
316 .withBody(mapper.writeValueAsString(defaultService))
317 .withStatus(HttpStatus.SC_OK)));
319 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
320 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
321 .withBody(mapper.writeValueAsString(serviceRecipe))
322 .withStatus(HttpStatus.SC_OK)));
324 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
325 RequestReferences requestReferences = new RequestReferences();
326 requestReferences.setInstanceId("1882939");
327 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
328 expectedResponse.setRequestReferences(requestReferences);
329 uri = servInstanceUriPrev7 + "v5";
330 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST, headers);
333 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
334 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
335 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
338 public void createServiceInstanceBpelStatusError() throws IOException{
339 ServiceRecipe serviceRecipe = new ServiceRecipe();
340 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
341 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
342 serviceRecipe.setAction(Action.createInstance.toString());
343 serviceRecipe.setId(1);
344 serviceRecipe.setRecipeTimeout(180);
345 Service defaultService = new Service();
346 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
349 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
350 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
351 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY)));
354 stubFor(get(urlMatching(".*/service/search/.*"))
355 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
356 .withBody(mapper.writeValueAsString(defaultService))
357 .withStatus(HttpStatus.SC_OK)));
359 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
360 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
361 .withBody(mapper.writeValueAsString(serviceRecipe))
362 .withStatus(HttpStatus.SC_OK)));
364 uri = servInstanceuri + "v5/serviceInstances";
365 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST);
367 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
370 public void createServiceInstanceBadGateway() throws IOException{
371 ServiceRecipe serviceRecipe = new ServiceRecipe();
372 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
373 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
374 serviceRecipe.setAction(Action.createInstance.toString());
375 serviceRecipe.setId(1);
376 serviceRecipe.setRecipeTimeout(180);
377 Service defaultService = new Service();
378 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
380 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
381 .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}")));
383 stubFor(get(urlMatching(".*/service/search/.*"))
384 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
385 .withBody(mapper.writeValueAsString(defaultService))
386 .withStatus(HttpStatus.SC_OK)));
388 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
389 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
390 .withBody(mapper.writeValueAsString(serviceRecipe))
391 .withStatus(HttpStatus.SC_OK)));
393 uri = servInstanceuri + "v5/serviceInstances";
394 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST);
396 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
399 public void createServiceInstanceEmptyResponse() throws IOException{
400 ServiceRecipe serviceRecipe = new ServiceRecipe();
401 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
402 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
403 serviceRecipe.setAction(Action.createInstance.toString());
404 serviceRecipe.setId(1);
405 serviceRecipe.setRecipeTimeout(180);
406 Service defaultService = new Service();
407 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
409 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
410 .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE)));
412 stubFor(get(urlMatching(".*/service/search/.*"))
413 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
414 .withBody(mapper.writeValueAsString(defaultService))
415 .withStatus(HttpStatus.SC_OK)));
417 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
418 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
419 .withBody(mapper.writeValueAsString(serviceRecipe))
420 .withStatus(HttpStatus.SC_OK)));
422 uri = servInstanceuri + "v5/serviceInstances";
423 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST);
425 assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value());
428 public void activateServiceInstanceNoRecipeALaCarte() throws IOException{
429 TestAppender.events.clear();
430 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
431 HttpHeaders requestIDheaders = new HttpHeaders();
432 requestIDheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d");
433 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST, requestIDheaders);
435 Service defaultService = new Service();
436 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
438 stubFor(get(urlMatching(".*/service/search/.*"))
439 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
440 .withBody(mapper.writeValueAsString(defaultService))
441 .withStatus(HttpStatus.SC_OK)));
444 stubFor(get(urlMatching(".*/serviceRecipe/search/findFirstByServiceModelUUIDAndAction?serviceModelUUID=d88da85c-d9e8-4f73-b837-3a72a431622a&action=activateInstance"))
445 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
446 .withStatus(HttpStatus.SC_NOT_FOUND)));
448 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
451 public void activateServiceInstanceNoRecipe() throws IOException{
452 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
453 Service defaultService = new Service();
454 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
455 stubFor(get(urlMatching(".*/service/search/.*"))
456 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
457 .withBody(mapper.writeValueAsString(defaultService))
458 .withStatus(HttpStatus.SC_OK)));
460 stubFor(get(urlMatching(".*/serviceRecipe/search/.*"))
461 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
462 .withStatus(HttpStatus.SC_NOT_FOUND)));
464 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST);
466 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
469 public void activateServiceInstance() throws IOException{
470 ServiceRecipe serviceRecipe = new ServiceRecipe();
471 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
472 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
473 serviceRecipe.setAction(Action.createInstance.toString());
474 serviceRecipe.setId(1);
475 serviceRecipe.setRecipeTimeout(180);
476 Service defaultService = new Service();
477 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
479 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
480 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
481 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
483 stubFor(get(urlMatching(".*/service/search/.*"))
484 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
485 .withBody(mapper.writeValueAsString(defaultService))
486 .withStatus(HttpStatus.SC_OK)));
488 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
489 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
490 .withBody(mapper.writeValueAsString(serviceRecipe))
491 .withStatus(HttpStatus.SC_OK)));
493 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
494 RequestReferences requestReferences = new RequestReferences();
495 requestReferences.setInstanceId("1882939");
496 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
497 expectedResponse.setRequestReferences(requestReferences);
498 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate";
499 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST, headers);
501 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
502 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
503 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
506 public void deactivateServiceInstance() throws IOException{
508 ServiceRecipe serviceRecipe = new ServiceRecipe();
509 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
510 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
511 serviceRecipe.setAction(Action.createInstance.toString());
512 serviceRecipe.setId(1);
513 serviceRecipe.setRecipeTimeout(180);
514 Service defaultService = new Service();
515 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
517 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
518 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
519 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
521 stubFor(get(urlMatching(".*/service/.*"))
522 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
523 .withBody(mapper.writeValueAsString(defaultService))
524 .withStatus(HttpStatus.SC_OK)));
526 stubFor(get(urlMatching(".*/service/search/.*"))
527 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
528 .withBody(mapper.writeValueAsString(defaultService))
529 .withStatus(HttpStatus.SC_OK)));
531 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
532 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
533 .withBody(mapper.writeValueAsString(serviceRecipe))
534 .withStatus(HttpStatus.SC_OK)));
537 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
538 RequestReferences requestReferences = new RequestReferences();
539 requestReferences.setInstanceId("1882939");
540 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
541 expectedResponse.setRequestReferences(requestReferences);
542 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate";
543 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST, headers);
545 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
546 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
547 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
550 public void deleteServiceInstance() throws IOException {
551 ServiceRecipe serviceRecipe = new ServiceRecipe();
552 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
553 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
554 serviceRecipe.setAction(Action.createInstance.toString());
555 serviceRecipe.setId(1);
556 serviceRecipe.setRecipeTimeout(180);
557 Service defaultService = new Service();
558 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
560 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
561 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
562 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
564 stubFor(get(urlMatching(".*/service/.*"))
565 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
566 .withBody(mapper.writeValueAsString(defaultService))
567 .withStatus(HttpStatus.SC_OK)));
569 stubFor(get(urlMatching(".*/service/search/.*"))
570 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
571 .withBody(mapper.writeValueAsString(defaultService))
572 .withStatus(HttpStatus.SC_OK)));
574 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
575 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
576 .withBody(mapper.writeValueAsString(serviceRecipe))
577 .withStatus(HttpStatus.SC_OK)));
579 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
580 RequestReferences requestReferences = new RequestReferences();
581 requestReferences.setInstanceId("1882939");
582 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
583 expectedResponse.setRequestReferences(requestReferences);
584 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/";
585 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE, headers);
587 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
588 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
589 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
592 public void assignServiceInstance() throws IOException {
593 ServiceRecipe serviceRecipe = new ServiceRecipe();
594 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
595 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
596 serviceRecipe.setAction(Action.createInstance.toString());
597 serviceRecipe.setId(1);
598 serviceRecipe.setRecipeTimeout(180);
599 Service defaultService = new Service();
600 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
602 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
603 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
604 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
606 stubFor(get(urlMatching(".*/service/.*"))
607 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
608 .withBody(mapper.writeValueAsString(defaultService))
609 .withStatus(HttpStatus.SC_OK)));
611 stubFor(get(urlMatching(".*/service/search/.*"))
612 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
613 .withBody(mapper.writeValueAsString(defaultService))
614 .withStatus(HttpStatus.SC_OK)));
616 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
617 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
618 .withBody(mapper.writeValueAsString(serviceRecipe))
619 .withStatus(HttpStatus.SC_OK)));
621 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
622 RequestReferences requestReferences = new RequestReferences();
623 requestReferences.setInstanceId("1882939");
624 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
625 expectedResponse.setRequestReferences(requestReferences);
626 uri = servInstanceuri + "v7" + "/serviceInstances/assign";
627 ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST, headers);
629 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
630 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
631 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
635 public void unassignServiceInstance() throws IOException {
636 ServiceRecipe serviceRecipe = new ServiceRecipe();
637 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
638 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
639 serviceRecipe.setAction(Action.createInstance.toString());
640 serviceRecipe.setId(1);
641 serviceRecipe.setRecipeTimeout(180);
642 Service defaultService = new Service();
643 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
645 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
646 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
647 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
649 stubFor(get(urlMatching(".*/service/.*"))
650 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
651 .withBody(mapper.writeValueAsString(defaultService))
652 .withStatus(HttpStatus.SC_OK)));
654 stubFor(get(urlMatching(".*/service/search/.*"))
655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
656 .withBody(mapper.writeValueAsString(defaultService))
657 .withStatus(HttpStatus.SC_OK)));
659 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
660 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
661 .withBody(mapper.writeValueAsString(serviceRecipe))
662 .withStatus(HttpStatus.SC_OK)));
664 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
665 RequestReferences requestReferences = new RequestReferences();
666 requestReferences.setInstanceId("1882939");
667 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
668 expectedResponse.setRequestReferences(requestReferences);
669 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign";
670 ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST, headers);
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 createPortConfiguration() 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 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
686 expectedResponse.setRequestReferences(requestReferences);
687 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
688 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
690 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
691 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
692 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
693 assertTrue(response.getBody().contains("1882939"));
696 public void createPortConfigurationEmptyProductFamilyId() throws IOException {
697 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
698 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST);
700 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
703 public void deletePortConfiguration() throws IOException {
704 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
705 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
706 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
709 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
710 RequestReferences requestReferences = new RequestReferences();
711 requestReferences.setInstanceId("1882939");
712 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
713 expectedResponse.setRequestReferences(requestReferences);
714 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970";
715 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE, headers);
717 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
718 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
719 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
722 public void enablePort() throws IOException {
723 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
724 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
725 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
727 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
728 RequestReferences requestReferences = new RequestReferences();
729 requestReferences.setInstanceId("1882939");
730 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
731 expectedResponse.setRequestReferences(requestReferences);
732 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort";
733 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST, headers);
735 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
736 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
737 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
740 public void disablePort() throws IOException {
741 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
742 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
743 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
745 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
746 RequestReferences requestReferences = new RequestReferences();
747 requestReferences.setInstanceId("1882939");
748 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
749 expectedResponse.setRequestReferences(requestReferences);
750 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort";
751 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST, headers);
753 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
754 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
755 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
758 public void activatePort() throws IOException {
759 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
760 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
761 .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 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
767 expectedResponse.setRequestReferences(requestReferences);
768 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate";
769 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST, headers);
771 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
772 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
773 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
776 public void deactivatePort() throws IOException {
777 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
778 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
779 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
781 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
782 RequestReferences requestReferences = new RequestReferences();
783 requestReferences.setInstanceId("1882939");
784 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
785 expectedResponse.setRequestReferences(requestReferences);
786 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate";
787 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST, headers);
789 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
790 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
791 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
794 public void addRelationships() throws IOException {
795 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
796 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
797 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
799 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
800 RequestReferences requestReferences = new RequestReferences();
801 requestReferences.setInstanceId("1882939");
802 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
803 expectedResponse.setRequestReferences(requestReferences);
804 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships";
805 ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST, headers);
807 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
808 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
809 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
812 public void removeRelationships() throws IOException {
813 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
814 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
815 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
817 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
818 RequestReferences requestReferences = new RequestReferences();
819 requestReferences.setInstanceId("1882939");
820 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
821 expectedResponse.setRequestReferences(requestReferences);
822 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships";
823 ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST, headers);
825 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
826 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
827 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
830 public void createVnfInstanceNoALaCarte() throws IOException {
831 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
832 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
833 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
836 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
837 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
838 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
839 .withStatus(org.apache.http.HttpStatus.SC_OK)));
841 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
842 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
843 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
844 .withStatus(org.apache.http.HttpStatus.SC_OK)));
846 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
847 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
848 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
849 .withStatus(org.apache.http.HttpStatus.SC_OK)));
852 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
853 RequestReferences requestReferences = new RequestReferences();
854 requestReferences.setInstanceId("1882939");
855 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
856 expectedResponse.setRequestReferences(requestReferences);
857 uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs";
858 ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST, headers);
860 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
861 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
862 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
865 public void createVnfInstance() throws IOException {
866 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
867 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
868 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
870 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672"))
871 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
872 .withBody(getWiremockResponseForCatalogdb("serviceVnf_Response.json"))
873 .withStatus(org.apache.http.HttpStatus.SC_OK)));
874 stubFor(get(urlMatching(".*/service/5df8b6de-2083-11e7-93ae-92361f002672/vnfCustomizations"))
875 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
876 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationsList_Response.json"))
877 .withStatus(org.apache.http.HttpStatus.SC_OK)));
880 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002672/vnfResources"))
881 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
882 .withBody(getWiremockResponseForCatalogdb("vnfResourcesCreateVnf_Response.json"))
883 .withStatus(org.apache.http.HttpStatus.SC_OK)));
885 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=createInstance"))
886 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
887 .withBody(getWiremockResponseForCatalogdb("vnfRecipeCreateInstance_Response.json"))
888 .withStatus(org.apache.http.HttpStatus.SC_OK)));
891 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
892 RequestReferences requestReferences = new RequestReferences();
893 requestReferences.setInstanceId("1882939");
894 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
895 expectedResponse.setRequestReferences(requestReferences);
896 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
897 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST, headers);
899 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
900 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
901 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
902 assertTrue(response.getBody().contains("1882939"));
905 public void createVnfWithServiceRelatedInstanceFail() throws IOException {
906 uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs";
907 ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST);
909 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
912 public void createVnfInstanceInvalidVnfResource() throws IOException {
913 uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs";
914 ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST);
916 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
917 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
918 assertEquals("No valid vnfResource is specified", realResponse.getServiceException().getText());
921 public void replaceVnfInstance() throws IOException {
922 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
923 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
924 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
926 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671"))
927 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
928 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_ReplaceVnf_Response.json"))
929 .withStatus(org.apache.http.HttpStatus.SC_OK)));
931 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002671/vnfResources"))
932 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
933 .withBody(getWiremockResponseForCatalogdb("vnfResources_ReplaceVnf_Response.json"))
934 .withStatus(org.apache.http.HttpStatus.SC_OK)));
936 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=replaceInstance"))
937 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
938 .withBody(getWiremockResponseForCatalogdb("vnfRecipeReplaceInstance_Response.json"))
939 .withStatus(org.apache.http.HttpStatus.SC_OK)));
941 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
942 RequestReferences requestReferences = new RequestReferences();
943 requestReferences.setInstanceId("1882939");
944 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
945 expectedResponse.setRequestReferences(requestReferences);
946 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
947 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST, headers);
949 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
950 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
951 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
954 public void replaceVnfRecreateInstance() throws IOException {
955 stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce"))
956 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
957 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
959 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
960 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
961 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
962 .withStatus(org.apache.http.HttpStatus.SC_OK)));
964 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
965 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
966 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
967 .withStatus(org.apache.http.HttpStatus.SC_OK)));
969 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=TEST&action=replaceInstance"))
970 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
971 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_Response.json"))
972 .withStatus(org.apache.http.HttpStatus.SC_OK)));
975 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
976 RequestReferences requestReferences = new RequestReferences();
977 requestReferences.setInstanceId("1882939");
978 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
979 expectedResponse.setRequestReferences(requestReferences);
980 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
981 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST, headers);
982 logger.debug(response.getBody());
984 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
985 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
986 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
989 public void recreateVnfInstance() throws IOException {
990 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
991 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
992 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
994 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
995 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
996 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response"))
997 .withStatus(org.apache.http.HttpStatus.SC_OK)));
999 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
1000 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1001 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1002 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1004 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]nfRole=GR-API-DEFAULT&action=recreateInstance"))
1005 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1006 .withBody(getWiremockResponseForCatalogdb("vnfRecipe_ResponseWorkflowAction.json"))
1007 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1010 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1011 RequestReferences requestReferences = new RequestReferences();
1012 requestReferences.setInstanceId("1882939");
1013 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1014 expectedResponse.setRequestReferences(requestReferences);
1015 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/recreate";
1016 ResponseEntity<String> response = sendRequest(inputStream("/VnfRecreate.json"), uri, HttpMethod.POST, headers);
1017 logger.debug(response.getBody());
1019 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1020 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1021 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1024 public void updateVnfInstance() throws IOException {
1025 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1026 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1027 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1029 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674"))
1030 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1031 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
1032 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1034 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
1035 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1036 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
1037 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1039 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1040 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
1041 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1042 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
1043 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1046 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1047 RequestReferences requestReferences = new RequestReferences();
1048 requestReferences.setInstanceId("1882939");
1049 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1050 expectedResponse.setRequestReferences(requestReferences);
1051 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1052 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT, headers);
1054 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1055 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1056 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1059 public void applyUpdatedConfig() throws IOException {
1060 stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate"))
1061 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1062 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1065 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1066 "[?]nfRole=GR-API-DEFAULT&action=applyUpdatedConfig"))
1067 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1068 .withBody(getWiremockResponseForCatalogdb("vnfRecipeApplyUpdatedConfig_Response.json"))
1069 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1072 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1073 RequestReferences requestReferences = new RequestReferences();
1074 requestReferences.setInstanceId("1882939");
1075 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1076 expectedResponse.setRequestReferences(requestReferences);
1077 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig";
1078 ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST, headers);
1080 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1081 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1082 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1085 public void deleteVnfInstanceV5() throws IOException {
1086 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1087 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1088 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1090 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
1091 "[?]nfRole=GR-API-DEFAULT&action=deleteInstance"))
1092 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1093 .withBody(getWiremockResponseForCatalogdb("vnfRecipeDelete_Response.json"))
1094 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1096 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1097 RequestReferences requestReferences = new RequestReferences();
1098 requestReferences.setInstanceId("1882939");
1099 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1100 expectedResponse.setRequestReferences(requestReferences);
1101 uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0";
1102 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE, headers);
1104 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1105 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1106 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1109 public void createVfModuleInstance() throws IOException {
1110 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1111 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1112 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1113 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1115 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1116 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1117 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1118 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1120 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1121 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1122 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1123 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1125 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1126 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1127 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1129 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1130 "[?]vfModuleModelUUID=20c4431c-246d-11e7-93ae-92361f002671&vnfComponentType=vfModule&action=createInstance"))
1131 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1132 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_Response.json"))
1133 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1135 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1136 RequestReferences requestReferences = new RequestReferences();
1137 requestReferences.setInstanceId("1882939");
1138 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1139 expectedResponse.setRequestReferences(requestReferences);
1140 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules";
1141 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST, headers);
1143 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1144 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1145 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1146 assertTrue(response.getBody().contains("1882939"));
1149 public void createVfModuleInstanceNoModelCustomization() throws IOException {
1150 stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra"))
1151 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1152 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1154 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1155 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1156 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1157 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1159 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1160 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1161 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1162 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1163 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1165 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1166 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1167 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1168 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1170 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1171 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1172 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1173 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1174 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1176 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
1177 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1178 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1179 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1181 stubFor(get(urlMatching(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1182 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1183 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1184 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1187 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction" +
1188 "[?]vnfComponentType=vfModule&action=createInstance"))
1189 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1190 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVNF_API_Response.json"))
1191 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1194 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1195 RequestReferences requestReferences = new RequestReferences();
1196 requestReferences.setInstanceId("1882939");
1197 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1198 expectedResponse.setRequestReferences(requestReferences);
1199 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1200 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST, headers);
1201 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1202 ObjectMapper mapper = new ObjectMapper();
1203 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1204 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1207 public void deleteVfModuleInstanceNoMatchingModelUUD() throws IOException {
1208 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1209 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1210 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1212 stubFor(get(urlMatching(".*/vnfResource/.*"))
1213 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1214 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1215 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1217 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources.*"))
1218 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1219 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1220 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1222 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1223 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1224 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1225 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1227 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672"))
1228 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1229 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1230 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1232 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002672/vfModule"))
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(".*/vfModule/066de97e-253e-11e7-93ae-92361f002672"))
1238 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1239 .withBody(getWiremockResponseForCatalogdb("vfModulePCM_Response.json"))
1240 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1242 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1243 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1244 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1245 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1246 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1249 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1250 RequestReferences requestReferences = new RequestReferences();
1251 requestReferences.setInstanceId("1882939");
1252 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1253 expectedResponse.setRequestReferences(requestReferences);
1254 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1255 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE, headers);
1258 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1259 ObjectMapper mapper = new ObjectMapper();
1260 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1261 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1264 public void createVfModuleInstanceNoRecipe() throws IOException {
1266 stubFor(get(urlMatching(".*/vnfResource/fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1267 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1268 .withBody(getWiremockResponseForCatalogdb("vnfResourceForVfModule_Response.json"))
1269 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1271 stubFor(get(urlMatching(".*/vnfResourceCustomization/search/findByModelInstanceNameAndVnfResources" +
1272 "[?]modelInstanceName=test&vnfResourceModelUUID=fe6478e4-ea33-3346-ac12-ab121484a3fe"))
1273 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1274 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomizationForVfModule_Response.json"))
1275 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1277 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002673/vfModuleCustomizations"))
1278 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1279 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationsPCM_Response.json"))
1280 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1282 stubFor(get(urlMatching(".*/vfModuleCustomization/search/findByModelCustomizationUUIDAndVfModuleModelUUID[?]" +
1283 "modelCustomizationUUID=b4ea86b4-253f-11e7-93ae-92361f002672&vfModuleModelUUID=066de97e-253e-11e7-93ae-92361f002672"))
1284 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1285 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationPCM_Response.json"))
1286 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1288 uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules";
1289 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST, headers);
1291 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1292 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
1293 assertEquals("No valid vfModuleCustomization is specified", realResponse.getServiceException().getText());
1296 public void replaceVfModuleInstance() throws IOException {
1297 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1298 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1299 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1301 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1302 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1303 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1304 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1305 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1307 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1308 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=replaceInstance"))
1309 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1310 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1311 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1313 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1314 RequestReferences requestReferences = new RequestReferences();
1315 requestReferences.setInstanceId("1882939");
1316 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1317 expectedResponse.setRequestReferences(requestReferences);
1318 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace";
1319 ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST, headers);
1321 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1322 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1323 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1326 public void updateVfModuleInstance() throws IOException {
1327 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1328 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1329 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1331 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
1332 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1333 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
1334 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1336 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
1337 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1338 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1339 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1341 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
1342 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1343 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1344 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1346 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1347 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=updateInstance"))
1348 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1349 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipe_GRAPI_Response.json"))
1350 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1353 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1354 RequestReferences requestReferences = new RequestReferences();
1355 requestReferences.setInstanceId("1882939");
1356 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1357 expectedResponse.setRequestReferences(requestReferences);
1358 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1359 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT, headers);
1360 logger.debug(response.getBody());
1362 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1363 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1364 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1367 public void createVfModuleNoModelType() throws IOException{
1368 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1369 expectedRecord.setRequestStatus("FAILED");
1370 expectedRecord.setAction("createInstance");
1371 expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified");
1372 expectedRecord.setProgress(100L);
1373 expectedRecord.setSource("VID");
1374 expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json"));
1375 expectedRecord.setLastModifiedBy("APIH");
1376 expectedRecord.setVfModuleName("testVfModule2");
1377 expectedRecord.setVfModuleModelName("serviceModel");
1378 expectedRecord.setRequestScope("vfModule");
1379 expectedRecord.setRequestAction("createInstance");
1380 expectedRecord.setRequestorId("zz9999");
1381 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1382 //VnfType is not sent in this request, should be blank in db
1383 expectedRecord.setVnfType("");
1384 uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules";
1386 ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers);
1388 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1391 public void inPlaceSoftwareUpdate() throws IOException {
1392 stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate"))
1393 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1394 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1396 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction[?]" +
1397 "nfRole=GR-API-DEFAULT&action=inPlaceSoftwareUpdate"))
1398 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1399 .withBody(getWiremockResponseForCatalogdb("vnfRecipeInPlaceUpdate_Response.json"))
1400 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1403 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1404 RequestReferences requestReferences = new RequestReferences();
1405 requestReferences.setInstanceId("1882939");
1406 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
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, headers);
1411 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1412 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1413 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1417 public void deleteVfModuleInstance() throws IOException {
1418 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1419 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1420 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1422 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1423 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1424 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1425 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1426 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1428 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1429 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1430 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1431 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1432 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1435 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1436 RequestReferences requestReferences = new RequestReferences();
1437 requestReferences.setInstanceId("1882939");
1438 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1439 expectedResponse.setRequestReferences(requestReferences);
1440 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1441 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE, headers);
1443 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1444 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1445 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1448 public void deleteVfModuleNoModelInvariantId() throws IOException {
1449 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1450 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1451 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1453 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1454 "[?]vfModuleModelUUID=VNF-API-DEFAULT&vnfComponentType=vfModule&action=deleteInstance"))
1455 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1456 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeleteVfModule_Response.json"))
1457 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1460 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1461 RequestReferences requestReferences = new RequestReferences();
1462 requestReferences.setInstanceId("1882939");
1463 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1464 expectedResponse.setRequestReferences(requestReferences);
1465 uri = servInstanceuri + "v7" + "/serviceInstances/196b4a84-0858-4317-a1f6-497e2e52ae43/vnfs/36e4f902-ec32-451e-8d53-e3edc19e40a4/vfModules/09f3a38d-933f-450a-8784-9e6c4dec3f72";
1466 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModuleNoModelInvariantId.json"), uri, HttpMethod.DELETE, headers);
1468 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1469 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1470 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1473 public void deactivateAndCloudDeleteVfModuleInstance() throws IOException {
1474 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1475 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1476 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1478 stubFor(get(urlMatching(".*/vfModule/search/findFirstVfModuleByModelInvariantUUIDAndModelVersion[?]" +
1479 "modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671&modelVersion=2"))
1480 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1481 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
1482 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1484 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1485 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=deactivateAndCloudDelete"))
1486 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1487 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeDeactivate_Response.json"))
1488 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1491 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1492 RequestReferences requestReferences = new RequestReferences();
1493 requestReferences.setInstanceId("1882939");
1494 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1495 expectedResponse.setRequestReferences(requestReferences);
1496 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete";
1497 ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST, headers);
1499 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1500 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1501 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1504 public void createVolumeGroupInstance() throws IOException {
1505 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1506 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1507 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1509 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1510 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1511 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1512 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1514 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1515 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1516 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1517 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1519 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1520 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=createInstance"))
1521 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1522 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1523 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1526 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1527 RequestReferences requestReferences = new RequestReferences();
1528 requestReferences.setInstanceId("1882939");
1529 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1530 expectedResponse.setRequestReferences(requestReferences);
1531 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups";
1532 ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST, headers);
1534 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1535 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1536 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1537 assertTrue(response.getBody().contains("1882939"));
1540 public void updateVolumeGroupInstance() throws IOException {
1541 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1542 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1543 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1545 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1546 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1547 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1548 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1550 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1551 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1552 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1553 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1555 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1556 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=updateInstance"))
1557 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1558 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1559 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1562 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1563 RequestReferences requestReferences = new RequestReferences();
1564 requestReferences.setInstanceId("1882939");
1565 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1566 expectedResponse.setRequestReferences(requestReferences);
1567 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1568 ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT, headers);
1570 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1571 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1572 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1575 public void deleteVolumeGroupInstance() throws IOException {
1576 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1577 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1578 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1580 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1581 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1582 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1584 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671"))
1585 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1586 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomizationVolGrp_Response.json"))
1587 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1589 stubFor(get(urlMatching(".*/vfModuleCustomization/b4ea86b4-253f-11e7-93ae-92361f002671/vfModule"))
1590 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1591 .withBody(getWiremockResponseForCatalogdb("vfModuleVolGroup_Response.json"))
1592 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1594 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
1595 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=volumeGroup&action=deleteInstance"))
1596 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1597 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVolGrp_GRAPI_Response.json"))
1598 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1601 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1602 RequestReferences requestReferences = new RequestReferences();
1603 requestReferences.setInstanceId("1882939");
1604 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1605 expectedResponse.setRequestReferences(requestReferences);
1606 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000";
1607 ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE, headers);
1609 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1610 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1611 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1614 public void createNetworkInstance() throws IOException {
1615 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1616 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1617 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1619 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1620 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1621 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1622 .withStatus(HttpStatus.SC_OK)));
1624 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1625 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1626 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1627 .withStatus(HttpStatus.SC_OK)));
1629 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1630 "modelName=GR-API-DEFAULT&action=createInstance"))
1631 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1632 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1633 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1636 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1637 RequestReferences requestReferences = new RequestReferences();
1638 requestReferences.setInstanceId("1882939");
1639 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1640 expectedResponse.setRequestReferences(requestReferences);
1641 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1642 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST, headers);
1644 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1645 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1646 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1649 public void updateNetworkInstance() throws IOException {
1650 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1651 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1652 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1654 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1655 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1656 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1657 .withStatus(HttpStatus.SC_OK)));
1659 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1660 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1661 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1662 .withStatus(HttpStatus.SC_OK)));
1664 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1665 "modelName=GR-API-DEFAULT&action=updateInstance"))
1666 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1667 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1668 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1670 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1671 RequestReferences requestReferences = new RequestReferences();
1672 requestReferences.setInstanceId("1882939");
1673 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1674 expectedResponse.setRequestReferences(requestReferences);
1675 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1676 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
1678 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1679 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1680 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1681 assertTrue(response.getBody().contains("1882939"));
1684 public void deleteNetworkInstance() throws IOException {
1685 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1686 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1687 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1689 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1690 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1691 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1692 .withStatus(HttpStatus.SC_OK)));
1694 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1695 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1696 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1697 .withStatus(HttpStatus.SC_OK)));
1699 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1700 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
1701 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1702 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1703 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1706 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1707 RequestReferences requestReferences = new RequestReferences();
1708 requestReferences.setInstanceId("1882939");
1709 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1710 expectedResponse.setRequestReferences(requestReferences);
1711 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1712 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
1714 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1715 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1716 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1719 public void deleteNetworkInstanceNoReqParams() throws IOException {
1720 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1721 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1722 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1724 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1725 "modelName=GR-API-DEFAULT&action=deleteInstance"))
1726 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1727 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1728 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1732 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1733 RequestReferences requestReferences = new RequestReferences();
1734 requestReferences.setInstanceId("1882939");
1735 requestReferences.setRequestSelfLink(createExpectedSelfLink("v6","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1736 expectedResponse.setRequestReferences(requestReferences);
1737 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1738 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE, headers);
1740 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1741 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1742 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1745 public void convertJsonToServiceInstanceRequestFail() throws IOException {
1747 InfraActiveRequests expectedRecord = new InfraActiveRequests();
1748 expectedRecord.setRequestStatus("FAILED");
1749 expectedRecord.setStatusMessage("Error mapping request: ");
1750 expectedRecord.setProgress(100L);
1751 expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json"));
1752 expectedRecord.setLastModifiedBy("APIH");
1753 expectedRecord.setRequestScope("network");
1754 expectedRecord.setRequestAction("deleteInstance");
1755 expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d");
1757 uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
1758 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE, headers);
1762 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1765 public void convertJsonToServiceInstanceRequestConfigurationFail() throws IOException {
1766 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort";
1767 ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST);
1769 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
1773 public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException {
1774 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1775 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1776 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1778 ServiceRecipe serviceRecipe = new ServiceRecipe();
1779 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1780 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1781 serviceRecipe.setAction(Action.createInstance.toString());
1782 serviceRecipe.setId(1);
1783 serviceRecipe.setRecipeTimeout(180);
1784 Service defaultService = new Service();
1785 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1787 stubFor(get(urlMatching(".*/service/.*"))
1788 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1789 .withBody(mapper.writeValueAsString(defaultService))
1790 .withStatus(HttpStatus.SC_OK)));
1792 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1793 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1794 .withBody(mapper.writeValueAsString(serviceRecipe))
1795 .withStatus(HttpStatus.SC_OK)));
1797 uri = servInstanceuri + "v7" + "/serviceInstances";
1798 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST, headers);
1801 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1802 RequestReferences requestReferences = new RequestReferences();
1803 requestReferences.setInstanceId("1882939");
1804 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1805 expectedResponse.setRequestReferences(requestReferences);
1807 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1808 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1809 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1813 public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException {
1814 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1815 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1816 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1818 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1819 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1820 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1821 .withStatus(HttpStatus.SC_OK)));
1823 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1824 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1825 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1826 .withStatus(HttpStatus.SC_OK)));
1828 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1829 "modelName=GR-API-DEFAULT&action=createInstance"))
1830 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1831 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1832 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1834 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1835 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST, headers);
1838 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1839 RequestReferences requestReferences = new RequestReferences();
1840 requestReferences.setInstanceId("1882939");
1841 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1842 expectedResponse.setRequestReferences(requestReferences);
1844 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1845 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1846 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1850 public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException {
1851 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1852 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1853 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1855 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1856 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST);
1859 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1860 RequestReferences requestReferences = new RequestReferences();
1861 requestReferences.setInstanceId("1882939");
1862 expectedResponse.setRequestReferences(requestReferences);
1864 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1868 public void createNetworkInstanceTestApiGrApi() throws IOException {
1869 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1870 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1871 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1873 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1874 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1875 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1876 .withStatus(HttpStatus.SC_OK)));
1878 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1879 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1880 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1881 .withStatus(HttpStatus.SC_OK)));
1883 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1884 "modelName=GR-API-DEFAULT&action=createInstance"))
1885 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1886 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
1887 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1889 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1890 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST, headers);
1893 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1894 RequestReferences requestReferences = new RequestReferences();
1895 requestReferences.setInstanceId("1882939");
1896 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1897 expectedResponse.setRequestReferences(requestReferences);
1899 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
1900 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
1901 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
1905 public void createNetworkInstanceTestApiVnfApi() throws IOException {
1906 stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance"))
1907 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1908 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1910 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
1911 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1912 .withBody(getWiremockResponseForCatalogdb("networkResourceCustomization_Response.json"))
1913 .withStatus(HttpStatus.SC_OK)));
1915 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac/networkResource"))
1916 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1917 .withBody(getWiremockResponseForCatalogdb("networkResource_Response.json"))
1918 .withStatus(HttpStatus.SC_OK)));
1920 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
1921 "modelName=VNF-API-DEFAULT&action=createInstance"))
1922 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1923 .withBody(getWiremockResponseForCatalogdb("networkRecipeVNF_API_Response.json"))
1924 .withStatus(org.apache.http.HttpStatus.SC_OK)));
1926 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks";
1927 ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST, headers);
1930 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1931 RequestReferences requestReferences = new RequestReferences();
1932 requestReferences.setInstanceId("1882939");
1933 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1934 expectedResponse.setRequestReferences(requestReferences);
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 activateServiceInstanceRequestStatus() throws IOException{
1943 ServiceRecipe serviceRecipe = new ServiceRecipe();
1944 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1945 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1946 serviceRecipe.setAction(Action.createInstance.toString());
1947 serviceRecipe.setId(1);
1948 serviceRecipe.setRecipeTimeout(180);
1949 Service defaultService = new Service();
1950 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1952 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
1953 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1954 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
1956 stubFor(get(urlMatching(".*/service/.*"))
1957 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1958 .withBody(mapper.writeValueAsString(defaultService))
1959 .withStatus(HttpStatus.SC_OK)));
1961 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
1962 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
1963 .withBody(mapper.writeValueAsString(serviceRecipe))
1964 .withStatus(HttpStatus.SC_OK)));
1967 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
1968 RequestReferences requestReferences = new RequestReferences();
1969 requestReferences.setInstanceId("1882939");
1970 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
1971 expectedResponse.setRequestReferences(requestReferences);
1972 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate";
1973 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST, headers);
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 invalidRequestId() throws IOException {
1982 String illegalRequestId = "1234";
1983 HttpHeaders ivalidRequestIdHeaders = new HttpHeaders();
1984 ivalidRequestIdHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, illegalRequestId);
1985 uri = servInstanceuri + "v5/serviceInstances";
1986 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, ivalidRequestIdHeaders);
1988 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
1989 assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID"));
1992 public void invalidBPELResponse() throws IOException{
1994 ServiceRecipe serviceRecipe = new ServiceRecipe();
1995 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
1996 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
1997 serviceRecipe.setAction(Action.createInstance.toString());
1998 serviceRecipe.setId(1);
1999 serviceRecipe.setRecipeTimeout(180);
2000 Service defaultService = new Service();
2001 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2003 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2004 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2005 .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2007 stubFor(get(urlMatching(".*/service/.*"))
2008 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2009 .withBody(mapper.writeValueAsString(defaultService))
2010 .withStatus(HttpStatus.SC_OK)));
2012 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2013 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2014 .withBody(mapper.writeValueAsString(serviceRecipe))
2015 .withStatus(HttpStatus.SC_OK)));
2017 uri = servInstanceuri + "v5/serviceInstances";
2018 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2020 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2021 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2022 assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText());
2025 public void unauthorizedBPELResponse() throws IOException{
2027 ServiceRecipe serviceRecipe = new ServiceRecipe();
2028 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2029 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2030 serviceRecipe.setAction(Action.createInstance.toString());
2031 serviceRecipe.setId(1);
2032 serviceRecipe.setRecipeTimeout(180);
2033 Service defaultService = new Service();
2034 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2036 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2037 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2038 .withBodyFile("Camunda/UnauthorizedResponse.json").withStatus(org.apache.http.HttpStatus.SC_UNAUTHORIZED)));
2040 stubFor(get(urlMatching(".*/service/.*"))
2041 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2042 .withBody(mapper.writeValueAsString(defaultService))
2043 .withStatus(HttpStatus.SC_OK)));
2045 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2046 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2047 .withBody(mapper.writeValueAsString(serviceRecipe))
2048 .withStatus(HttpStatus.SC_OK)));
2050 uri = servInstanceuri + "v5/serviceInstances";
2051 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2053 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2054 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2055 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2059 public void invalidBPELResponse2() throws IOException{
2061 ServiceRecipe serviceRecipe = new ServiceRecipe();
2062 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2063 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2064 serviceRecipe.setAction(Action.createInstance.toString());
2065 serviceRecipe.setId(1);
2066 serviceRecipe.setRecipeTimeout(180);
2067 Service defaultService = new Service();
2068 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2070 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2071 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2072 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2074 stubFor(get(urlMatching(".*/service/.*"))
2075 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2076 .withBody(mapper.writeValueAsString(defaultService))
2077 .withStatus(HttpStatus.SC_OK)));
2079 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2080 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2081 .withBody(mapper.writeValueAsString(serviceRecipe))
2082 .withStatus(HttpStatus.SC_OK)));
2083 uri = servInstanceuri + "v5/serviceInstances";
2084 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2086 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2087 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2088 assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500"));
2092 public void createMacroServiceInstance() throws IOException{
2093 ServiceRecipe serviceRecipe = new ServiceRecipe();
2094 serviceRecipe.setOrchestrationUri("/mso/async/services/CreateMacroServiceNetworkVnf");
2095 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2096 serviceRecipe.setAction(Action.createInstance.toString());
2097 serviceRecipe.setId(1);
2098 serviceRecipe.setRecipeTimeout(180);
2099 Service defaultService = new Service();
2100 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2102 stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf"))
2103 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2104 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2106 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2107 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2108 .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2110 stubFor(get(urlMatching(".*/service/.*"))
2111 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2112 .withBody(mapper.writeValueAsString(defaultService))
2113 .withStatus(HttpStatus.SC_OK)));
2115 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2116 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2117 .withBody(mapper.writeValueAsString(serviceRecipe))
2118 .withStatus(HttpStatus.SC_OK)));
2121 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2122 RequestReferences requestReferences = new RequestReferences();
2123 requestReferences.setInstanceId("1882939");
2124 requestReferences.setRequestSelfLink(createExpectedSelfLink("v5","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2125 expectedResponse.setRequestReferences(requestReferences);
2126 uri = servInstanceUriPrev7 + "v5";
2127 ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST, headers);
2130 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2131 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2132 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2136 public void testUserParams() throws IOException {
2137 ObjectMapper mapper = new ObjectMapper();
2138 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2139 RequestParameters requestParameters = request.getRequestDetails().getRequestParameters();
2140 String userParamsTxt = inputStream("/userParams.txt");
2142 List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters);
2143 System.out.println(userParams);
2144 assertTrue(userParams.size() > 0);
2145 assertTrue(userParams.get(0).containsKey("name"));
2146 assertTrue(userParams.get(0).containsKey("value"));
2147 assertEquals(userParamsTxt.replaceAll("\\s+", ""), userParams.toString().replaceAll("\\s+", ""));
2151 public void testConfigureCloudConfig() throws IOException {
2152 ObjectMapper mapper = new ObjectMapper();
2153 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2154 CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters());
2156 assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId());
2157 assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId());
2161 public void testMapToLegacyRequest() throws IOException {
2162 ObjectMapper mapper = new ObjectMapper();
2163 ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class);
2164 ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class);
2165 servInstances.mapToLegacyRequest(request.getRequestDetails());
2166 System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request));
2167 assertThat(request, sameBeanAs(expected));
2170 public void scaleOutVfModule() throws IOException {
2171 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2172 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2173 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2175 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671"))
2176 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2177 .withBody(getWiremockResponseForCatalogdb("vfModuleCustomization_Response.json"))
2178 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2180 stubFor(get(urlMatching(".*/vfModuleCustomization/cb82ffd8-252a-11e7-93ae-92361f002671/vfModule"))
2181 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2182 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2183 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2185 stubFor(get(urlMatching(".*/vfModule/20c4431c-246d-11e7-93ae-92361f002671"))
2186 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2187 .withBody(getWiremockResponseForCatalogdb("vfModule_Response.json"))
2188 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2191 stubFor(get(urlMatching(".*/vnfComponentsRecipe/search/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction" +
2192 "[?]vfModuleModelUUID=GR-API-DEFAULT&vnfComponentType=vfModule&action=scaleOut"))
2193 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2194 .withBody(getWiremockResponseForCatalogdb("vnfComponentRecipeVfModuleScaleOut_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2196 stubFor(get(urlMatching(".*/vfModule/search/findByModelInvariantUUIDOrderByModelVersionDesc[?]modelInvariantUUID=78ca26d0-246d-11e7-93ae-92361f002671"))
2197 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2198 .withBody(getWiremockResponseForCatalogdb("vfModulesListByInvariantId_Response.json")).withStatus(org.apache.http.HttpStatus.SC_OK)));
2201 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2202 RequestReferences requestReferences = new RequestReferences();
2203 requestReferences.setInstanceId("1882939");
2204 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2205 expectedResponse.setRequestReferences(requestReferences);
2206 uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut";
2207 ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST, headers);
2209 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2210 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2211 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2212 assertTrue(response.getBody().contains("1882939"));
2215 public void createServiceInstanceBadResponse() throws IOException{
2216 ServiceRecipe serviceRecipe = new ServiceRecipe();
2217 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2218 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2219 serviceRecipe.setAction(Action.createInstance.toString());
2220 serviceRecipe.setId(1);
2221 serviceRecipe.setRecipeTimeout(180);
2222 Service defaultService = new Service();
2223 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2225 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2226 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2227 .withBodyFile("Camunda/TestBadResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2229 stubFor(get(urlMatching(".*/service/.*"))
2230 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2231 .withBody(mapper.writeValueAsString(defaultService))
2232 .withStatus(HttpStatus.SC_OK)));
2234 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2235 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2236 .withBody(mapper.writeValueAsString(serviceRecipe))
2237 .withStatus(HttpStatus.SC_OK)));
2239 uri = servInstanceuri + "v5/serviceInstances";
2240 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2242 assertEquals(Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode().value());
2243 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2244 assertEquals("Exception caught mapping Camunda JSON response to object", realResponse.getServiceException().getText());
2247 public void createServiceInstanceDuplicateError() throws IOException{
2248 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2249 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2250 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2252 uri = servInstanceuri + "v5/serviceInstances";
2253 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2255 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2256 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2257 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2260 public void createServiceInstanceDuplicateHistoryCheck() throws IOException{
2261 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2262 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2263 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2264 .withStatus(HttpStatus.SC_ACCEPTED)));
2265 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2266 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2267 .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2269 uri = servInstanceuri + "v5/serviceInstances";
2270 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2272 assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value());
2273 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2274 assertEquals("Error: Locked instance - This service (testService9) already has a request being worked with a status of UNLOCKED (RequestId - f0a35706-efc4-4e27-80ea-a995d7a2a40f). The existing request must finish or be cleaned up before proceeding.", realResponse.getServiceException().getText());
2277 public void createServiceInstanceDuplicateHistoryCheckException() throws IOException{
2278 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2279 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2280 .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json")
2281 .withStatus(HttpStatus.SC_ACCEPTED)));
2282 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2283 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2284 .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2286 uri = servInstanceuri + "v5/serviceInstances";
2287 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2289 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2290 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2291 assertEquals("Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2294 public void createServiceInstanceDuplicate() throws IOException{
2295 stubFor(post(urlMatching(".*/infraActiveRequests/checkInstanceNameDuplicate"))
2296 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2297 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2299 uri = servInstanceuri + "v5/serviceInstances";
2300 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2302 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2303 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2304 assertEquals("Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2308 public void createServiceInstanceSaveError() throws IOException{
2309 ServiceRecipe serviceRecipe = new ServiceRecipe();
2310 serviceRecipe.setOrchestrationUri("/mso/async/services/WorkflowActionBB");
2311 serviceRecipe.setServiceModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2312 serviceRecipe.setAction(Action.createInstance.toString());
2313 serviceRecipe.setId(1);
2314 serviceRecipe.setRecipeTimeout(180);
2315 Service defaultService = new Service();
2316 defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a");
2317 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2318 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2319 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2320 stubFor(get(urlMatching(".*/service/.*"))
2321 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2322 .withBody(mapper.writeValueAsString(defaultService))
2323 .withStatus(HttpStatus.SC_OK)));
2325 stubFor(get(urlMatching(".*/serviceRecipe/search.*"))
2326 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2327 .withBody(mapper.writeValueAsString(serviceRecipe))
2328 .withStatus(HttpStatus.SC_OK)));
2330 uri = servInstanceuri + "v5/serviceInstances";
2331 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST, headers);
2333 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2334 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2335 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2338 public void createPortConfigurationSaveError() throws IOException {
2339 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2340 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2341 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2342 stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator"))
2343 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2344 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2346 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2347 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST, headers);
2349 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2350 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2351 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2354 public void createPortConfigDbUpdateError() throws IOException {
2355 stubFor(post(urlMatching(".*/infraActiveRequests/"))
2356 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2357 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
2359 uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations";
2360 ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST, headers);
2362 assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
2363 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2364 assertEquals("Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException: 500 Server Error", realResponse.getServiceException().getText());
2367 public void vnfUpdateWithNetworkInstanceGroup() throws IOException{
2368 TestAppender.events.clear();
2369 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2370 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2371 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2373 stubFor(get(urlMatching(".*/vnfResourceCustomization/2ccae1b4-7d9e-46fa-a452-9180ce008d17"))
2374 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2375 .withBody(getWiremockResponseForCatalogdb("vnfResourceCustomization_Response.json"))
2376 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2378 stubFor(get(urlMatching(".*/vnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002674/vnfResources"))
2379 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2380 .withBody(getWiremockResponseForCatalogdb("vnfResources_Response.json"))
2381 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2383 stubFor(get(urlMatching(".*/vnfRecipe/search/findFirstVnfRecipeByNfRoleAndAction" +
2384 "[?]nfRole=GR-API-DEFAULT&action=updateInstance"))
2385 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2386 .withBody(getWiremockResponseForCatalogdb("UpdateVnfRecipe_Response.json"))
2387 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2388 headers.set(ONAPLogConstants.Headers.PARTNER_NAME, "VID");
2390 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2391 RequestReferences requestReferences = new RequestReferences();
2392 requestReferences.setInstanceId("1882939");
2393 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2394 expectedResponse.setRequestReferences(requestReferences);
2395 uri = servInstanceuri + "v7/serviceInstances/e05864f0-ab35-47d0-8be4-56fd9619ba3c/vnfs/f501ce76-a9bc-4601-9837-74fd9f4d5eca";
2396 ResponseEntity<String> response = sendRequest(inputStream("/VnfwithNeteworkInstanceGroup.json"), uri, HttpMethod.PUT, headers);
2398 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2399 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2400 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2401 assertEquals(response.getHeaders().get(TRANSACTION_ID).get(0), "32807a28-1a14-4b88-b7b3-2950918aa76d");
2403 for(ILoggingEvent logEvent : TestAppender.events){
2404 if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging") &&
2405 logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")){
2406 Map<String,String> mdc = logEvent.getMDCPropertyMap();
2407 assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
2408 assertEquals("VID",mdc.get(PARTNERNAME));
2413 public void createInstanceGroup() throws IOException{
2414 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2415 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2416 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2419 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2420 RequestReferences requestReferences = new RequestReferences();
2421 requestReferences.setInstanceId("1882939");
2422 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2423 expectedResponse.setRequestReferences(requestReferences);
2424 uri = servInstanceuri + "/v7/instanceGroups";
2425 ResponseEntity<String> response = sendRequest(inputStream("/CreateInstanceGroup.json"), uri, HttpMethod.POST, headers);
2428 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2429 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2430 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2433 public void deleteInstanceGroup() throws IOException{
2434 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2435 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2436 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2439 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2440 RequestReferences requestReferences = new RequestReferences();
2441 requestReferences.setInstanceId("1882939");
2442 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2443 expectedResponse.setRequestReferences(requestReferences);
2444 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2445 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, headers);
2448 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2449 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2450 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2453 public void deleteInstanceGroupNoRequestIdHeader() throws IOException{
2454 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2455 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE);
2457 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2458 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2459 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-RequestID header is specified");
2462 public void deleteInstanceGroupNoPartnerNameHeader() throws IOException{
2463 HttpHeaders noPartnerHeaders = new HttpHeaders();
2464 noPartnerHeaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2465 noPartnerHeaders.set(REQUESTOR_ID, "xxxxxx");
2466 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2467 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noPartnerHeaders);
2469 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2470 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2471 assertEquals(realResponse.getServiceException().getText(), "No valid X-ONAP-PartnerName header is specified");
2474 public void deleteInstanceGroupNoRquestorIdHeader() throws IOException{
2475 HttpHeaders noRequestorIdHheaders = new HttpHeaders();
2476 noRequestorIdHheaders.set(ONAPLogConstants.Headers.REQUEST_ID, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2477 noRequestorIdHheaders.set(ONAPLogConstants.Headers.PARTNER_NAME, "eca3a1b1-43ab-457e-ab1c-367263d148b4");
2479 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2480 RequestReferences requestReferences = new RequestReferences();
2481 requestReferences.setInstanceId("1882939");
2482 expectedResponse.setRequestReferences(requestReferences);
2483 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c";
2484 ResponseEntity<String> response = sendRequest(null, uri, HttpMethod.DELETE, noRequestorIdHheaders);
2487 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2488 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2489 assertEquals(realResponse.getServiceException().getText(), "No valid X-RequestorID header is specified");
2492 public void addMembers() throws IOException{
2493 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2494 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2495 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2497 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2498 RequestReferences requestReferences = new RequestReferences();
2499 requestReferences.setInstanceId("1882939");
2500 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2501 expectedResponse.setRequestReferences(requestReferences);
2502 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/addMembers";
2503 ResponseEntity<String> response = sendRequest(inputStream("/AddMembers.json"), uri, HttpMethod.POST, headers);
2506 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2507 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2508 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2511 public void removeMembers() throws IOException{
2512 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2513 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2514 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2516 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2517 RequestReferences requestReferences = new RequestReferences();
2518 requestReferences.setInstanceId("1882939");
2519 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2520 expectedResponse.setRequestReferences(requestReferences);
2521 uri = servInstanceuri + "/v7/instanceGroups/e05864f0-ab35-47d0-8be4-56fd9619ba3c/removeMembers";
2522 ResponseEntity<String> response = sendRequest(inputStream("/RemoveMembers.json"), uri, HttpMethod.POST, headers);
2525 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2526 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2527 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2530 public void deleteNetworkInstanceNoCustomizationEntry() throws IOException {
2531 stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB"))
2532 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2533 .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2535 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2536 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2537 .withStatus(HttpStatus.SC_NOT_FOUND)));
2539 stubFor(get(urlMatching(".*/networkRecipe/search/findFirstByModelNameAndAction[?]" +
2540 "modelName=VNF-API-DEFAULT&action=deleteInstance"))
2541 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2542 .withBody(getWiremockResponseForCatalogdb("networkRecipe_Response.json"))
2543 .withStatus(org.apache.http.HttpStatus.SC_OK)));
2546 ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse();
2547 RequestReferences requestReferences = new RequestReferences();
2548 requestReferences.setInstanceId("1882939");
2549 requestReferences.setRequestSelfLink(createExpectedSelfLink("v7","32807a28-1a14-4b88-b7b3-2950918aa76d"));
2550 expectedResponse.setRequestReferences(requestReferences);
2551 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2552 ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE, headers);
2554 assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value());
2555 ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
2556 assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
2559 public void updateNetworkInstanceNoCustomizationEntry() throws IOException {
2560 stubFor(get(urlMatching(".*/networkResourceCustomization/3bdbb104-476c-483e-9f8b-c095b3d308ac"))
2561 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2562 .withStatus(HttpStatus.SC_NOT_FOUND)));
2564 uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb";
2565 ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT, headers);
2567 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
2568 RequestError realResponse = errorMapper.readValue(response.getBody(), RequestError.class);
2569 assertEquals(realResponse.getServiceException().getText(), "No valid modelCustomizationId for networkResourceCustomization lookup is specified");
2573 public void setServiceTypeTestALaCarte() throws JsonProcessingException{
2574 String requestScope = ModelType.service.toString();
2575 Boolean aLaCarteFlag = true;
2576 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2577 RequestDetails requestDetails = new RequestDetails();
2578 RequestInfo requestInfo = new RequestInfo();
2579 requestInfo.setSource("VID");
2580 requestDetails.setRequestInfo(requestInfo);
2581 sir.setRequestDetails(requestDetails);
2582 Service defaultService = new Service();
2583 defaultService.setServiceType("testServiceTypeALaCarte");
2585 stubFor(get(urlMatching(".*/service/search/.*"))
2586 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2587 .withBody(mapper.writeValueAsString(defaultService))
2588 .withStatus(HttpStatus.SC_OK)));
2590 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2591 assertEquals(serviceType, "testServiceTypeALaCarte");
2594 public void setServiceTypeTest() throws JsonProcessingException{
2595 String requestScope = ModelType.service.toString();
2596 Boolean aLaCarteFlag = false;
2597 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2598 RequestDetails requestDetails = new RequestDetails();
2599 RequestInfo requestInfo = new RequestInfo();
2600 ModelInfo modelInfo = new ModelInfo();
2601 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2602 requestInfo.setSource("VID");
2603 requestDetails.setModelInfo(modelInfo);
2604 requestDetails.setRequestInfo(requestInfo);
2605 sir.setRequestDetails(requestDetails);
2606 Service defaultService = new Service();
2607 defaultService.setServiceType("testServiceType");
2609 stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2610 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2611 .withBody(mapper.writeValueAsString(defaultService))
2612 .withStatus(HttpStatus.SC_OK)));
2614 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2615 assertEquals(serviceType, "testServiceType");
2618 public void setServiceTypeTestDefault() throws JsonProcessingException{
2619 String requestScope = ModelType.service.toString();
2620 Boolean aLaCarteFlag = false;
2621 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2622 RequestDetails requestDetails = new RequestDetails();
2623 RequestInfo requestInfo = new RequestInfo();
2624 ModelInfo modelInfo = new ModelInfo();
2625 modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
2626 requestInfo.setSource("VID");
2627 requestDetails.setModelInfo(modelInfo);
2628 requestDetails.setRequestInfo(requestInfo);
2629 sir.setRequestDetails(requestDetails);
2630 Service defaultService = new Service();
2631 defaultService.setServiceType("testServiceType");
2633 stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
2634 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2635 .withStatus(HttpStatus.SC_NOT_FOUND)));
2636 stubFor(get(urlMatching(".*/service/search/.*"))
2637 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2638 .withBody(mapper.writeValueAsString(defaultService))
2639 .withStatus(HttpStatus.SC_OK)));
2641 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2642 assertEquals(serviceType, "testServiceType");
2645 public void setServiceTypeTestNetwork() throws JsonProcessingException{
2646 String requestScope = ModelType.network.toString();
2647 Boolean aLaCarteFlag = null;
2648 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2649 RequestDetails requestDetails = new RequestDetails();
2650 RequestInfo requestInfo = new RequestInfo();
2651 ModelInfo modelInfo = new ModelInfo();
2652 modelInfo.setModelName("networkModelName");
2653 requestInfo.setSource("VID");
2654 requestDetails.setModelInfo(modelInfo);
2655 requestDetails.setRequestInfo(requestInfo);
2656 sir.setRequestDetails(requestDetails);
2658 String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
2659 assertEquals(serviceType, "networkModelName");
2662 public void setServiceInstanceIdInstanceGroupTest() throws JsonParseException, JsonMappingException, IOException{
2663 String requestScope = "instanceGroup";
2664 ServiceInstancesRequest sir = mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class);
2665 assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", servInstances.setServiceInstanceId(requestScope, sir));
2668 public void setServiceInstanceIdTest(){
2669 String requestScope = "vnf";
2670 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2671 sir.setServiceInstanceId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2672 assertEquals("f0a35706-efc4-4e27-80ea-a995d7a2a40f", servInstances.setServiceInstanceId(requestScope, sir));
2675 public void setServiceInstanceIdReturnNullTest(){
2676 String requestScope = "vnf";
2677 ServiceInstancesRequest sir = new ServiceInstancesRequest();
2678 assertNull(servInstances.setServiceInstanceId(requestScope, sir));
2681 public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException{
2682 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2683 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2684 .withBodyFile("Camunda/HistoryCheckResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2686 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2687 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2688 boolean inProgress = false;
2689 inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
2690 assertTrue(inProgress);
2693 public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException{
2694 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2695 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2696 .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK)));
2698 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2699 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2700 boolean inProgress = false;
2701 inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
2702 assertFalse(inProgress);
2705 public void camundaHistoryCheckNotInProgressTest()throws ContactCamundaException, RequestDbFailureException{
2706 stubFor(get(("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f"))
2707 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
2708 .withBodyFile("Camunda/HistoryCheckResponseCompleted.json").withStatus(org.apache.http.HttpStatus.SC_OK)));
2710 InfraActiveRequests duplicateRecord = new InfraActiveRequests();
2711 duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f");
2712 boolean inProgress = false;
2713 inProgress = servInstances.camundaHistoryCheck(duplicateRecord, null);
2714 assertFalse(inProgress);
2717 public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
2718 String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
2719 String key = "07a7159d3bf51a0e53be7a8f89699be7";
2720 HttpHeaders headers = servInstances.setCamundaHeaders(encryptedAuth, key);
2721 List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
2722 String expectedAcceptedType = "application/json";
2723 assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
2724 String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
2725 String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
2726 assertEquals(expectedBasicAuth, basicAuth);