diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
24 files changed, 2169 insertions, 1475 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java index 2baa54fdec..a63b778a1f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java @@ -20,10 +20,7 @@ package org.onap.so.apihandlerinfra; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -33,11 +30,17 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.junit.Ignore; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.apache.http.HttpStatus; +import org.junit.Before; import org.junit.Test; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.ServiceException; import org.springframework.http.HttpEntity; @@ -45,43 +48,65 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.http.Fault; public class E2EServiceInstancesTest extends BaseTest { -private ObjectMapper mapper = new ObjectMapper(); +private final ObjectMapper mapper = new ObjectMapper(); private final String e2eServInstancesUri = "/e2eServiceInstances/"; + + @Before + public void init() throws JsonProcessingException { + stubFor(post(urlPathEqualTo("/testOrchestrationUri")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(post(urlPathEqualTo("/infraActiveRequests/")).withRequestBody(equalToJson("{\"clientRequestId\":null,\"action\":null,\"requestStatus\":\"FAILED\",\"statusMessage\":\"Error parsing request: No valid requestorId is specified\",\"progress\":100,\"startTime\":1533541051247,\"endTime\":1533541051247,\"source\":null,\"vnfId\":null,\"vnfName\":null,\"vnfType\":null,\"serviceType\":null,\"aicNodeClli\":null,\"tenantId\":null,\"provStatus\":null,\"vnfParams\":null,\"vnfOutputs\":null,\"requestBody\":\"{\\r\\n \\\"service\\\":{\\r\\n \\\"name\\\":\\\"so_test4\\\",\\r\\n \\\"description\\\":\\\"so_test2\\\",\\r\\n \\\"serviceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561519\\\",\\r\\n \\\"serviceUuid\\\":\\\"592f9437-a9c0-4303-b9f6-c445bb7e9814\\\",\\r\\n \\\"globalSubscriberId\\\":\\\"123457\\\",\\r\\n \\\"serviceType\\\":\\\"voLTE\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"resources\\\":[\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vIMS\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vBAS-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-vMME-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"vEPC\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"61c3e96e-0970-4871-b6e0-3b6de7561516\\\",\\r\\n \\\"resourceUuid\\\":\\\"62c3e96e-0970-4871-b6e0-3b6de7561512\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n {\\r\\n \\\"vnfProfileId\\\":\\\"zte-CSCF-1.0\\\",\\r\\n \\\"locationConstraints\\\":{\\r\\n \\\"vimId\\\":\\\"4050083f-465f-4838-af1e-47a545222ad1\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"underlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561513\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561514\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"resourceName\\\":\\\"overlayvpn\\\",\\r\\n \\\"resourceInvariantUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561517\\\",\\r\\n \\\"resourceUuid\\\":\\\"60c3e96e-0970-4871-b6e0-3b6de7561518\\\",\\r\\n \\\"parameters\\\":{\\r\\n \\\"locationConstraints\\\":[\\r\\n\\r\\n ]\\r\\n }\\r\\n }\\r\\n ],\\r\\n \\\"requestInputs\\\":{\\r\\n \\\"externalDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"m6000_mng_ip\\\":\\\"181.18.20.2\\\",\\r\\n \\\"externalCompanyFtpDataNetworkName\\\":\\\"Flow_out_net\\\",\\r\\n \\\"externalPluginManageNetworkName\\\":\\\"plugin_net_2014\\\",\\r\\n \\\"externalManageNetworkName\\\":\\\"mng_net_2017\\\",\\r\\n \\\"sfc_data_network\\\":\\\"sfc_data_net_2016\\\",\\r\\n \\\"NatIpRange\\\":\\\"210.1.1.10-210.1.1.20\\\",\\r\\n \\\"location\\\":\\\"4050083f-465f-4838-af1e-47a545222ad0\\\",\\r\\n \\\"sdncontroller\\\":\\\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\\\"\\r\\n }\\r\\n }\\r\\n\\r\\n }\\r\\n\\r\\n}\",\"responseBody\":null,\"lastModifiedBy\":\"APIH\",\"modifyTime\":null,\"requestType\":null,\"volumeGroupId\":null,\"volumeGroupName\":null,\"vfModuleId\":null,\"vfModuleName\":null,\"vfModuleModelName\":null,\"aaiServiceId\":null,\"aicCloudRegion\":null,\"callBackUrl\":null,\"correlator\":null,\"serviceInstanceId\":null,\"serviceInstanceName\":null,\"requestScope\":\"service\",\"requestAction\":\"createInstance\",\"networkId\":null,\"networkName\":null,\"networkType\":null,\"requestorId\":null,\"configurationId\":null,\"configurationName\":null,\"operationalEnvId\":null,\"operationalEnvName\":null,\"requestURI\":\"d167c9d0-1785-4e93-b319-996ebbcc3272\"}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + Service defaultService = new Service(); + defaultService.setModelUUID("d88da85c-d9e8-4f73-b837-3a72a431622a"); + ServiceRecipe serviceRecipe = new ServiceRecipe(); + serviceRecipe.setServiceModelUUID(defaultService.getModelUUID()); + serviceRecipe.setAction(Action.scaleInstance.name()); + serviceRecipe.setRecipeTimeout(180); + serviceRecipe.setOrchestrationUri("/testOrchestrationUri"); + + stubFor(get(urlPathEqualTo("/service/search/findFirstByModelNameOrderByModelVersionDesc")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(defaultService)) + .withStatus(HttpStatus.SC_OK))); + + stubFor(get(urlPathEqualTo("/serviceRecipe/search/findFirstByServiceModelUUIDAndAction")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(serviceRecipe)) + .withStatus(HttpStatus.SC_OK))); + + } public String inputStream(String JsonInput)throws IOException{ JsonInput = "src/test/resources/E2EServiceInstancesTest" + JsonInput; - String input = new String(Files.readAllBytes(Paths.get(JsonInput))); - return input; + return new String(Files.readAllBytes(Paths.get(JsonInput))); } public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type",MediaType.APPLICATION_JSON); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath)); - HttpEntity<String> request = new HttpEntity<String>(requestJson, headers); - ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), + HttpEntity<String> request = new HttpEntity<>(requestJson, headers); + + return restTemplate.exchange(builder.toUriString(), reqMethod, request, String.class); - - return response; } - //Currently returning a 500 response - @Ignore + @Test - public void createE2EServiceInstanceNoRequestInfo() throws JsonParseException, JsonMappingException, IOException{ - String uri = e2eServInstancesUri + "v5"; + public void createE2EServiceInstanceNoRequestInfo() throws IOException{ + String uri = e2eServInstancesUri + "v3"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST); assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); } @Test - public void updateE2EServiceInstanceJSONMappingError() throws JsonParseException, JsonMappingException, IOException{ + public void updateE2EServiceInstanceJSONMappingError() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity<String> response = sendRequest(inputStream("/CompareModelRequest.json"), uri, HttpMethod.PUT); @@ -90,7 +115,7 @@ private ObjectMapper mapper = new ObjectMapper(); assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed")); } @Test - public void updateE2EServiceInstanceNoRequestorId() throws JsonParseException, JsonMappingException, IOException{ + public void updateE2EServiceInstanceNoRequestorId() throws IOException{ RequestError expectedResponse = new RequestError(); ServiceException exception = new ServiceException(); exception.setMessageId("SVC0002"); @@ -105,7 +130,7 @@ private ObjectMapper mapper = new ObjectMapper(); assertThat(realResponse, sameBeanAs(expectedResponse)); } @Test - public void deleteE2EServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{ + public void deleteE2EServiceInstance() throws IOException{ RequestError expectedResponse = new RequestError(); ServiceException exception = new ServiceException(); exception.setMessageId("SVC1000"); @@ -115,12 +140,10 @@ private ObjectMapper mapper = new ObjectMapper(); String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity<String> response = sendRequest(inputStream("/DeleteRequest.json"), uri, HttpMethod.DELETE); - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertThat(realResponse, sameBeanAs(expectedResponse)); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); } @Test - public void deleteE2EServiceInstanceNotValid() throws JsonParseException, JsonMappingException, IOException{ + public void deleteE2EServiceInstanceNotValid() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.DELETE); @@ -129,14 +152,14 @@ private ObjectMapper mapper = new ObjectMapper(); assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed")); } @Test - public void getE2EServiceInstanceNullOperationalStatus() throws JsonParseException, JsonMappingException, IOException{ + public void getE2EServiceInstanceNullOperationalStatus() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.GET); assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatusCode().value()); } @Test - public void scaleE2EServiceInstanceMappingError() throws JsonParseException, JsonMappingException, IOException{ + public void scaleE2EServiceInstanceMappingError() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST); @@ -145,22 +168,35 @@ private ObjectMapper mapper = new ObjectMapper(); assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed")); } @Test - public void scaleE2EServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - RequestError expectedResponse = new RequestError(); - ServiceException exception = new ServiceException(); - exception.setMessageId("SVC1000"); - exception.setText("No communication to catalog DB null"); - expectedResponse.setServiceException(exception); - + public void scaleE2EServiceInstance() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/scale"; ResponseEntity<String> response = sendRequest(inputStream("/ScaleRequest.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertThat(realResponse, sameBeanAs(expectedResponse)); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + } + + @Test + public void updateE2EServiceInstance() throws IOException{ + String uri = e2eServInstancesUri + "v3/9b9f02c0-298b-458a-bc9c-be3692e4f35e"; + ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.PUT); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + } + + @Test + public void getE2EServiceInstance() throws IOException{ + OperationStatus status = new OperationStatus(); + status.setOperationId("operationId"); + status.setServiceId("9b9f02c0-298b-458a-bc9c-be3692e4f35e"); + stubFor(get(urlPathEqualTo("/operationStatusRepository/search/findOneByServiceIdAndOperationId")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(mapper.writeValueAsString(status)) + .withStatus(HttpStatus.SC_OK))); + String uri = e2eServInstancesUri + "v3/9b9f02c0-298b-458a-bc9c-be3692e4f35e/operations/operationId"; + ResponseEntity<String> response = sendRequest("", uri, HttpMethod.GET); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); } @Test - public void compareModelWithTargetVersionBadRequest() throws JsonParseException, JsonMappingException, IOException{ + public void compareModelWithTargetVersionBadRequest() throws IOException{ String uri = e2eServInstancesUri + "v5/9b9f02c0-298b-458a-bc9c-be3692e4f35e/modeldifferences"; ResponseEntity<String> response = sendRequest(inputStream("/Request.json"), uri, HttpMethod.POST); @@ -169,7 +205,7 @@ private ObjectMapper mapper = new ObjectMapper(); assertTrue(realResponse.getServiceException().getText().contains("Mapping of request to JSON object failed")); } @Test - public void compareModelWithTargetVersion() throws JsonParseException, JsonMappingException, IOException{ + public void compareModelWithTargetVersion() throws IOException{ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile("Camunda/SuccessfulResponse.json").withStatus(org.apache.http.HttpStatus.SC_ACCEPTED))); @@ -183,7 +219,7 @@ private ObjectMapper mapper = new ObjectMapper(); assertEquals(expectedResponse, actualResponse); } @Test - public void compareModelWithTargetVersionEmptyResponse() throws JsonParseException, JsonMappingException, IOException{ + public void compareModelWithTargetVersionEmptyResponse() throws IOException{ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance")) .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE))); @@ -201,7 +237,7 @@ private ObjectMapper mapper = new ObjectMapper(); assertThat(realResponse, sameBeanAs(expectedResponse)); } @Test - public void compareModelWithTargetVersionBadBpelResponse() throws JsonParseException, JsonMappingException, IOException{ + public void compareModelWithTargetVersionBadBpelResponse() throws IOException{ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY))); @@ -214,7 +250,7 @@ private ObjectMapper mapper = new ObjectMapper(); assertTrue(realResponse.getServiceException().getText().contains("Request Failed due to BPEL error with HTTP Status")); } @Test - public void compareModelWithTargetVersionNoBPELResponse() throws JsonParseException, JsonMappingException, IOException{ + public void compareModelWithTargetVersionNoBPELResponse() throws IOException{ stubFor(post(urlPathEqualTo("/mso/async/services/CompareModelofE2EServiceInstance")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBody("{}").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY))); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java index c9d83efced..5d6aa43a9b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java @@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import java.io.IOException; @@ -57,62 +58,80 @@ import ch.qos.logback.classic.spi.ILoggingEvent; public class ManualTasksTest extends BaseTest{ - private final String basePath = "/tasks/v1/"; - - - - @Test - public void testCreateOpEnvObjectMapperError() throws IOException { - TestAppender.events.clear(); - stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); - - String taskId = "55"; - TasksRequest taskReq = new TasksRequest(); - RequestDetails reqDetail = new RequestDetails(); - RequestInfo reqInfo = new RequestInfo(); - reqInfo.setRequestorId("testId"); - reqInfo.setSource("testSource"); - reqInfo.setResponseValue(ValidResponses.skip); - reqDetail.setRequestInfo(reqInfo); - taskReq.setRequestDetails(reqDetail); - - //expected response - TaskRequestReference expectedResponse = new TaskRequestReference(); - expectedResponse.setTaskId(taskId); - - headers.set("Accept", MediaType.APPLICATION_JSON); - headers.set("Content-Type", MediaType.APPLICATION_JSON); - headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321"); - headers.set(MsoLogger.CLIENT_ID, "VID"); - HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers); - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete"); - ResponseEntity<String> response = restTemplate.exchange( - builder.toUriString(), - HttpMethod.POST, entity, String.class); - - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class); - - - //then - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - assertThat(realResponse, sameBeanAs(expectedResponse)); - ILoggingEvent logEvent = TestAppender.events.get(0); - Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertEquals("987654321", mdc.get(MsoLogger.REQUEST_ID)); - assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID)); - assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); - assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); - assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); - assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); - assertEquals("987654321", response.getHeaders().get("X-TransactionID").get(0)); - MDC.remove(MsoLogger.CLIENT_ID); - - } + private final String basePath = "/tasks/v1/"; + + + + @Test + public void testCreateOpEnvObjectMapperError() throws IOException { + TestAppender.events.clear(); + stubFor(post(urlPathEqualTo("/sobpmnengine/task/55/complete")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); + + String taskId = "55"; + TasksRequest taskReq = new TasksRequest(); + RequestDetails reqDetail = new RequestDetails(); + RequestInfo reqInfo = new RequestInfo(); + reqInfo.setRequestorId("testId"); + reqInfo.setSource("testSource"); + reqInfo.setResponseValue(ValidResponses.skip); + reqDetail.setRequestInfo(reqInfo); + taskReq.setRequestDetails(reqDetail); + + //expected response + TaskRequestReference expectedResponse = new TaskRequestReference(); + expectedResponse.setTaskId(taskId); + + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); + headers.set(MsoLogger.ECOMP_REQUEST_ID, "987654321"); + headers.set(MsoLogger.CLIENT_ID, "VID"); + HttpEntity<TasksRequest> entity = new HttpEntity<TasksRequest>(taskReq, headers); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath) + taskId + "/complete"); + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.POST, entity, String.class); + + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + TaskRequestReference realResponse = mapper.readValue(response.getBody(), TaskRequestReference.class); + + + //then + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + assertThat(realResponse, sameBeanAs(expectedResponse)); + + for(ILoggingEvent logEvent : TestAppender.events) + if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && + logEvent.getMarker().getName().equals("ENTRY") + ){ + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE)); + }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && + logEvent.getMarker().getName().equals("EXIT")){ + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.ENDTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); + assertEquals("202",mdc.get(MsoLogger.RESPONSECODE)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE)); + assertNotNull(mdc.get(MsoLogger.RESPONSEDESC)); + assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); + assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); + assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); + assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); + } + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java index 7feea9a456..63dc96f485 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java @@ -192,6 +192,7 @@ public class MsoRequestTest extends BaseTest { {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/CloudConfigurationConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5}, {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6}, {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/DeactivateAndCloudDeleteCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateAndCloudDelete, 7}, + {"No valid cloudConfiguration is specified", mapper.readValue(inputStream("/CloudConfiguration/ScaleOutNoCloudConfig.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyLcpCloudConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid lcpCloudRegionId is specified", mapper.readValue(inputStream("/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6}, {"No valid tenantId is specified", mapper.readValue(inputStream("/CloudConfiguration/EmptyTenantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, @@ -206,6 +207,7 @@ public class MsoRequestTest extends BaseTest { {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 6}, {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/ModelCustomization.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 6}, {"No valid modelCustomizationId or modelCustomizationName is specified", mapper.readValue(inputStream("/ModelInfo/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.replaceInstance, 5}, + {"No valid modelCustomizationId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid model-info is specified", mapper.readValue(inputStream("/ModelInfo/ModelInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelInvariantId format is specified", mapper.readValue(inputStream("/ModelInfo/InvalidModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 2}, {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 4}, @@ -215,11 +217,14 @@ public class MsoRequestTest extends BaseTest { {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ModelInvariantIdConfiguration.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 3}, {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v5DeactivateModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deactivateInstance, 5}, {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/v3UpdateNetworkBad.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4}, + {"No valid modelInvariantId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelInvariantId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/VfModuleModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.deleteInstance, 4}, + {"No valid modelName is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid modelType is specified", mapper.readValue(inputStream("/ModelInfo/ModelTypeNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionVfModule.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3}, {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionServiceCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3}, + {"No valid modelVersion is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersion.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ConfigurationModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 4}, @@ -229,6 +234,7 @@ public class MsoRequestTest extends BaseTest { {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v2ModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.disablePort, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ModelVersionIdCreate.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/v5ActivateModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, + {"No valid modelVersionId is specified", mapper.readValue(inputStream("/ModelInfo/ScaleOutNoModelVersionId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, //ValidationException for Platform and LineOfBusiness {"No valid lineOfBusinessName is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/EmptyLineOfBusiness.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid platform is specified", mapper.readValue(inputStream("/PlatformAndLineOfBusiness/Platform.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 6}, @@ -261,6 +267,7 @@ public class MsoRequestTest extends BaseTest { {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5EnablePortNoRelatedInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.enablePort, 5}, {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v5CreateNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/v4RelatedInstancesNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 4}, + {"No valid related instances is specified", mapper.readValue(inputStream("/RelatedInstances/ScaleOutNoRelatedInstances.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid related service instance for vfModule request is specified", mapper.readValue(inputStream("/RelatedInstances/VfModuleRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, {"No valid related service instance for vnf request is specified", mapper.readValue(inputStream("/RelatedInstances/VnfRelatedInstancesService.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, {"No valid related service instance for volumeGroup request is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesServiceInstance.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.activateInstance, 5}, @@ -275,6 +282,7 @@ public class MsoRequestTest extends BaseTest { {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfoNull.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 5}, {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.applyUpdatedConfig, 6}, {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/RequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.inPlaceSoftwareUpdate, 6}, + {"No valid requestInfo is specified", mapper.readValue(inputStream("/RequestInfo/ScaleOutNoRequestInfo.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7}, {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/VnfProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3}, {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, 3}, {"No valid productFamilyId is specified", mapper.readValue(inputStream("/RequestInfo/NetworkProductFamilyId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.updateInstance, 3}, @@ -310,7 +318,9 @@ public class MsoRequestTest extends BaseTest { {"No valid model-info in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/Network.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7}, {"No valid modelCustomizationId in userParams vfModule resources is specified", mapper.readValue(inputStream("/RequestParameters/VfModuleModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7}, {"No valid modelCustomizationId in userParams vnf resources is specified", mapper.readValue(inputStream("/RequestParameters/VnfModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7}, - {"No valid modelCustomizationId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7} + {"No valid modelCustomizationId in userParams network resources is specified", mapper.readValue(inputStream("/RequestParameters/NetworkModelCustomizationId.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, 7}, + //Validation for ConfigurationParameters + {"No valid configuration parameters is specified", mapper.readValue(inputStream("/ConfigurationParameters/NoConfigurationParameters.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.scaleOut, 7} }); } @Test diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 1ab66561b0..48d424c8d1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -73,1335 +73,1386 @@ import ch.qos.logback.classic.spi.ILoggingEvent; public class ServiceInstancesTest extends BaseTest{ - - @Autowired - private InfraActiveRequestsRepository iar; - - @Autowired - private ServiceInstances servInstances; - - private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/"; - private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/"; - private String uri; - - public String inputStream(String JsonInput)throws IOException{ - JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput; - String input = new String(Files.readAllBytes(Paths.get(JsonInput))); - return input; - } - - public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ - headers.set("Accept", MediaType.APPLICATION_JSON); - headers.set("Content-Type",MediaType.APPLICATION_JSON); - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath)); - - HttpEntity<String> request = new HttpEntity<String>(requestJson, headers); - ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), - reqMethod, request, String.class); - - return response; - } - - @Test - public void test_mapJSONtoMSOStyle() throws IOException{ - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - String testRequest= inputStream("/ServiceInstanceDefault.json"); - String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null); - ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class); - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid()); - assertEquals("modelInstanceName",modelInfo.getModelInstanceName()); - assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid()); - assertEquals("10",modelInfo.getModelUuid()); - - } - @Test - public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{ - TestAppender.events.clear(); - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); - headers.set(MsoLogger.CLIENT_ID, "VID"); - //expect - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - //then - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - ILoggingEvent logEvent = TestAppender.events.get(0); - Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", mdc.get(MsoLogger.REQUEST_ID)); - assertEquals("VID", mdc.get(MsoLogger.CLIENT_ID)); - MDC.remove(MsoLogger.CLIENT_ID); - assertTrue(response.getBody().contains("1882939")); - assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0)); - assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); - assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); - assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0)); - assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", response.getHeaders().get("X-TransactionID").get(0)); + + @Autowired + private InfraActiveRequestsRepository iar; + + @Autowired + private ServiceInstances servInstances; + + private final String servInstanceuri = "/onap/so/infra/serviceInstantiation/"; + private final String servInstanceUriPrev7 = "/onap/so/infra/serviceInstances/"; + private String uri; + + public String inputStream(String JsonInput)throws IOException{ + JsonInput = "src/test/resources/ServiceInstanceTest" + JsonInput; + String input = new String(Files.readAllBytes(Paths.get(JsonInput))); + return input; + } + + public ResponseEntity<String> sendRequest(String requestJson, String uriPath, HttpMethod reqMethod){ + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type",MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(uriPath)); + + HttpEntity<String> request = new HttpEntity<String>(requestJson, headers); + ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), + reqMethod, request, String.class); + + return response; + } + + @Test + public void test_mapJSONtoMSOStyle() throws IOException{ + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + String testRequest= inputStream("/ServiceInstanceDefault.json"); + String resultString = servInstances.mapJSONtoMSOStyle(testRequest, null, false, null); + ServiceInstancesRequest sir = mapper.readValue(resultString, ServiceInstancesRequest.class); + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + assertEquals("f7ce78bb-423b-11e7-93f8-0050569a796",modelInfo.getModelCustomizationUuid()); + assertEquals("modelInstanceName",modelInfo.getModelInstanceName()); + assertEquals("f7ce78bb-423b-11e7-93f8-0050569a7965",modelInfo.getModelInvariantUuid()); + assertEquals("10",modelInfo.getModelUuid()); + + } + @Test + public void createServiceInstanceVIDDefault() throws JsonParseException, JsonMappingException, IOException{ + TestAppender.events.clear(); + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + headers.set(MsoLogger.CLIENT_ID, "VID"); + //expect + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //then + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + + + + for(ILoggingEvent logEvent : TestAppender.events) + if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && + logEvent.getMarker().getName().equals("ENTRY") + ){ + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE)); + }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && + logEvent.getMarker().getName().equals("EXIT")){ + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.ENDTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); + assertEquals("202",mdc.get(MsoLogger.RESPONSECODE)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("COMPLETE",mdc.get(MsoLogger.STATUSCODE)); + assertNotNull(mdc.get(MsoLogger.RESPONSEDESC)); + assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); + assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); + assertEquals("5.0.0", response.getHeaders().get("X-LatestVersion").get(0)); + } - //ExpectedRecord - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("IN_PROGRESS"); - expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json")); - expectedRecord.setAction("createInstance"); - expectedRecord.setSource("VID"); - expectedRecord.setVnfId("1882938"); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setServiceInstanceId("1882939"); - expectedRecord.setServiceInstanceName("testService9"); - expectedRecord.setRequestScope("service"); - expectedRecord.setRequestorId("xxxxxx"); - expectedRecord.setRequestAction("createInstance"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString()); - - } - @Test - public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expect - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceUriPrev7 + "v5"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - //then - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY))); - - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}"))); - - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE))); - - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{ - uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; - headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST); - - //ExpectedRecord - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("FAILED"); - expectedRecord.setAction("activateInstance"); - expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB."); - expectedRecord.setProgress(new Long(100)); - expectedRecord.setSource("VID"); - expectedRecord.setVnfId("1882938"); - expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968"); - expectedRecord.setServiceInstanceName("testService7"); - expectedRecord.setRequestScope("service"); - expectedRecord.setRequestAction("activateInstance"); - expectedRecord.setRequestorId("xxxxxx"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString()); - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{ - uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/assign"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertTrue(response.getBody().contains("1882939")); - } - @Test - public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException { - uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void enablePort() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void disablePort() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void activatePort() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deactivatePort() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void addRelationships() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships"; - ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void removeRelationships() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships"; - ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs"; - ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3"; - headers.set(MsoLogger.TRANSACTION_ID, requestId); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; - ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - InfraActiveRequests record = iar.findOneByRequestId(requestId); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertTrue(response.getBody().contains("1882939")); - assertEquals(record.getVnfType(), "vSAMP12/test"); - } - @Test - public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException { - uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs"; - ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - } - @Test - public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException { - uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; - ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified")); - } - @Test - public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; - ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; - ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST); - logger.debug(response.getBody()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5"; - headers.set(MsoLogger.TRANSACTION_ID, requestId); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig"; - ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - InfraActiveRequests record = iar.findOneByRequestId(requestId); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertNull(record.getVnfType()); - } - @Test - public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0"; - ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules"; - ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertTrue(response.getBody().contains("1882939")); - } - @Test - public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; - ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException { - uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; - ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified")); - } - @Test - public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; - ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT); - logger.debug(response.getBody()); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{ - headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("FAILED"); - expectedRecord.setAction("createInstance"); - expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified"); - expectedRecord.setProgress(new Long(100)); - expectedRecord.setSource("VID"); - expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json")); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setVfModuleName("testVfModule2"); - expectedRecord.setVfModuleModelName("serviceModel"); - expectedRecord.setRequestScope("vfModule"); - expectedRecord.setRequestAction("createInstance"); - expectedRecord.setRequestorId("zz9999"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - //VnfType is not sent in this request, should be blank in db - expectedRecord.setVnfType(""); - uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules"; - - ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST); - //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString()); - assertNotNull(requestRecord.getStartTime()); - assertNotNull(requestRecord.getEndTime()); - } - @Test - public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate"; - ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - InfraActiveRequests req = new InfraActiveRequests(); - req.setRequestStatus("IN_PROGRESS"); - req.setAction("inPlaceSoftwareUpdate"); - req.setProgress(new Long(10)); - req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); - req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908"); - req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033"); - req.setRequestScope("vnf"); - req.setVnfName("duplicateCheck123"); - req.setRequestAction("inPlaceSoftwareUpdate"); - req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - iar.save(req); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate"; - ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value()); - - InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json")); - - assertNotNull(newRecord.getServiceInstanceId()); - assertNotNull(newRecord.getVnfId()); - - } - - @Test - public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete"; - ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups"; - ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertTrue(response.getBody().contains("1882939")); - } - @Test - public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4"; - headers.set(MsoLogger.TRANSACTION_ID, requestId); - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - InfraActiveRequests record = iar.findOneByRequestId(requestId); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertEquals(record.getNetworkType(), "TestNetworkType"); - } - @Test - public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; - ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - assertTrue(response.getBody().contains("1882939")); - } - @Test - public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - @Test - public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException { - headers.set(MsoLogger.TRANSACTION_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); - //ExpectedRecord - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("FAILED"); - expectedRecord.setStatusMessage("Error mapping request: "); - expectedRecord.setProgress(new Long(100)); - expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json")); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setRequestScope("network"); - expectedRecord.setRequestAction("deleteInstance"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; - ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE); - - //ActualRecord - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage")); - assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: ")); - assertNotNull(requestRecord.getStartTime()); - assertNotNull(requestRecord.getEndTime()); - } - @Test - public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException { - uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort"; - ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v7" + "/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void createNetworkInstanceTestApiGrApi() throws IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void createNetworkInstanceTestApiVnfApi() throws IOException { - stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; - ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST); - - //expected response - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); - - InfraActiveRequests expectedRecord = new InfraActiveRequests(); - expectedRecord.setRequestStatus("FAILED"); - expectedRecord.setAction("activateInstance"); - expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB."); - expectedRecord.setProgress(new Long(100)); - expectedRecord.setSource("VID"); - expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); - expectedRecord.setLastModifiedBy("APIH"); - expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999"); - expectedRecord.setServiceInstanceName("testService1234"); - expectedRecord.setRequestScope("service"); - expectedRecord.setRequestAction("activateInstance"); - expectedRecord.setRequestorId("xxxxxx"); - expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - //expect - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); - - //then - assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus()); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void invalidRequestId() throws IOException { - String illegalRequestId = "1234"; - headers.set("X-ECOMP-RequestID", illegalRequestId); - - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID")); - } - @Test - public void invalidBPELResponse() throws IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText()); - } - - @Test - public void invalidBPELResponse2() throws IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - uri = servInstanceuri + "v5/serviceInstances"; - ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); - assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500")); - } - - @Test - public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{ - stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); - - //expect - ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); - RequestReferences requestReferences = new RequestReferences(); - requestReferences.setInstanceId("1882939"); - expectedResponse.setRequestReferences(requestReferences); - uri = servInstanceUriPrev7 + "v5"; - ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST); - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - //then - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); - assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); - } - - @Test - public void testUserParams() throws JsonParseException, JsonMappingException, IOException { - ObjectMapper mapper = new ObjectMapper(); - ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); - RequestParameters requestParameters = request.getRequestDetails().getRequestParameters(); - String userParamsTxt = inputStream("/userParams.txt"); - - List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters); - System.out.println(userParams); - assertTrue(userParams.size() > 0); - assertTrue(userParams.get(0).containsKey("name")); - assertTrue(userParams.get(0).containsKey("value")); - assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+",""))); - } - - @Test - public void testConfigureCloudConfig() throws IOException { - ObjectMapper mapper = new ObjectMapper(); - ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); - CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters()); - - assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId()); - assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId()); - } - - @Test - public void testMapToLegacyRequest() throws IOException { - ObjectMapper mapper = new ObjectMapper(); - ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); - ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class); - servInstances.mapToLegacyRequest(request.getRequestDetails()); - System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request)); - assertThat(request, sameBeanAs(expected)); - } + //ExpectedRecord + InfraActiveRequests expectedRecord = new InfraActiveRequests(); + expectedRecord.setRequestStatus("IN_PROGRESS"); + expectedRecord.setRequestBody(inputStream("/ServiceInstanceDefault.json")); + expectedRecord.setAction("createInstance"); + expectedRecord.setSource("VID"); + expectedRecord.setVnfId("1882938"); + expectedRecord.setLastModifiedBy("APIH"); + expectedRecord.setServiceInstanceId("1882939"); + expectedRecord.setServiceInstanceName("testService9"); + expectedRecord.setRequestScope("service"); + expectedRecord.setRequestorId("xxxxxx"); + expectedRecord.setRequestAction("createInstance"); + expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + + //ActualRecord + InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("modifyTime").toString()); + + } + @Test + public void createServiceInstanceServiceInstancesUri() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/CreateGenericALaCarteServiceInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expect + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceUriPrev7 + "v5"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev7.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //then + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createServiceInstanceBpelStatusError() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceStatusError.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void createServiceInstanceBadGateway() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{}"))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void createServiceInstanceBadData() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withStatus(org.apache.http.HttpStatus.SC_BAD_GATEWAY).withBody("{I AM REALLY BAD}"))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceBadGateway.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void createServiceInstanceEmptyResponse() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withFault(Fault.EMPTY_RESPONSE))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEmpty.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.BAD_GATEWAY.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void activateServiceInstanceNoRecipeALaCarte() throws JsonParseException, JsonMappingException, IOException{ + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; + headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json"), uri, HttpMethod.POST); + + //ExpectedRecord + InfraActiveRequests expectedRecord = new InfraActiveRequests(); + expectedRecord.setRequestStatus("FAILED"); + expectedRecord.setAction("activateInstance"); + expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB."); + expectedRecord.setProgress(new Long(100)); + expectedRecord.setSource("VID"); + expectedRecord.setVnfId("1882938"); + expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); + expectedRecord.setLastModifiedBy("APIH"); + expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7968"); + expectedRecord.setServiceInstanceName("testService7"); + expectedRecord.setRequestScope("service"); + expectedRecord.setRequestAction("activateInstance"); + expectedRecord.setRequestorId("xxxxxx"); + expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + + //ActualRecord + InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString()); + assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void activateServiceInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException{ + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceNoRecipe.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void activateServiceInstance() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/activate"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivate.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deactivateServiceInstance() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/DeactivateInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/deactivate"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivate.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deleteServiceInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/DeleteInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a8868/"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDelete.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void assignServiceInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/AssignServiceInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/assign"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceAssign.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void unassignServiceInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/UnassignServiceInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/unassign"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceUnassign.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createPortConfiguration() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + headers.set("X-TransactionID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePortConfiguration.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertTrue(response.getBody().contains("1882939")); + } + @Test + public void createPortConfigurationEmptyProductFamilyId() throws JsonParseException, JsonMappingException, IOException { + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceParseFail.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void deletePortConfiguration() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstance.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void enablePort() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/enablePort"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceEnablePort.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void disablePort() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/disablePort"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDisablePort.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void activatePort() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/activate"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceActivatePort.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deactivatePort() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/configurations/f7ce78bb-423b-11e7-93f8-0050569a7970/deactivate"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDeactivatePort.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void addRelationships() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/addRelationships"; + ResponseEntity<String> response = sendRequest(inputStream("/AddRelationships.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void removeRelationships() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/ALaCarteOrchestrator")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/removeRelationships"; + ResponseEntity<String> response = sendRequest(inputStream("/RemoveRelationships.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createVnfInstanceNoALaCarte() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/49585b36-2b5a-443a-8b10-c75d34bb5e46/vnfs"; + ResponseEntity<String> response = sendRequest(inputStream("/VnfCreateDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createVnfInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c3"; + headers.set(MsoLogger.ONAP_REQUEST_ID, requestId); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; + ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstance.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + InfraActiveRequests record = iar.findOneByRequestId(requestId); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertTrue(response.getBody().contains("1882939")); + assertEquals(record.getVnfType(), "vSAMP12/test"); + } + @Test + public void createVnfWithServiceRelatedInstanceFail() throws JsonParseException, JsonMappingException, IOException { + uri = servInstanceUriPrev7 + "v6" + "/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs"; + ResponseEntity<String> response = sendRequest(inputStream("/VnfWithServiceRelatedInstanceFail.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + } + @Test + public void createVnfInstanceInvalidVnfResource() throws JsonParseException, JsonMappingException, IOException { + uri = servInstanceuri + "v7" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs"; + ResponseEntity<String> response = sendRequest(inputStream("/NoVnfResource.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertTrue(realResponse.getServiceException().getText().equals("No valid vnfResource is specified")); + } + @Test + public void replaceVnfInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; + ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnf.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void replaceVnfRecreateInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/RecreateInfraVce")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; + ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVnfRecreate.json"), uri, HttpMethod.POST); + logger.debug(response.getBody()); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void updateVnfInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/UpdateVnf.json"), uri, HttpMethod.PUT); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void applyUpdatedConfig() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/VnfConfigUpdate")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c5"; + headers.set(MsoLogger.ONAP_REQUEST_ID, requestId); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/applyUpdatedConfig"; + ResponseEntity<String> response = sendRequest(inputStream("/ApplyUpdatedConfig.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + InfraActiveRequests record = iar.findOneByRequestId(requestId); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertNull(record.getVnfType()); + } + @Test + public void deleteVnfInstanceV5() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v5" + "/serviceInstances/e446b97d-9c35-437a-95a2-6b4c542c4507/vnfs/49befbfe-fccb-421d-bb4c-0734a43f5ea0"; + ResponseEntity<String> response = sendRequest(inputStream("/DeleteVnfV5.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/CreateVfModuleInfra")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules"; + ResponseEntity<String> response = sendRequest(inputStream("/VfModuleWithRelatedInstances.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertTrue(response.getBody().contains("1882939")); + } + @Test + public void createVfModuleInstanceNoModelCustomization() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; + ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelCustomization.json"), uri, HttpMethod.POST); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deleteVfModuleInstanceNoMatchingModelUUD() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoMatchingModelUUID.json"), uri, HttpMethod.DELETE); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createVfModuleInstanceNoRecipe() throws JsonParseException, JsonMappingException, IOException { + uri = servInstanceuri + "v6" + "/serviceInstances/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules"; + ResponseEntity<String> response = sendRequest(inputStream("/VfModuleInvalid.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertTrue(realResponse.getServiceException().getText().equals("No valid vfModuleCustomization is specified")); + } + @Test + public void replaceVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/replace"; + ResponseEntity<String> response = sendRequest(inputStream("/ReplaceVfModule.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void updateVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/UpdateVfModule.json"), uri, HttpMethod.PUT); + logger.debug(response.getBody()); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createVfModuleNoModelType() throws JsonParseException, JsonMappingException, IOException{ + headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + InfraActiveRequests expectedRecord = new InfraActiveRequests(); + expectedRecord.setRequestStatus("FAILED"); + expectedRecord.setAction("createInstance"); + expectedRecord.setStatusMessage("Error parsing request: No valid modelType is specified"); + expectedRecord.setProgress(new Long(100)); + expectedRecord.setSource("VID"); + expectedRecord.setRequestBody(inputStream("/VfModuleNoModelType.json")); + expectedRecord.setLastModifiedBy("APIH"); + expectedRecord.setVfModuleName("testVfModule2"); + expectedRecord.setVfModuleModelName("serviceModel"); + expectedRecord.setRequestScope("vfModule"); + expectedRecord.setRequestAction("createInstance"); + expectedRecord.setRequestorId("zz9999"); + expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + //VnfType is not sent in this request, should be blank in db + expectedRecord.setVnfType(""); + uri = servInstanceuri + "v5/serviceInstances/32807a28-1a14-4b88-b7b3-2950918aa76d/vnfs/32807a28-1a14-4b88-b7b3-2950918aa76d/vfModules"; + + ResponseEntity<String> response = sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST); + //ActualRecord + InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals(sameBeanAs(expectedRecord).toString(), sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").toString()); + assertNotNull(requestRecord.getStartTime()); + assertNotNull(requestRecord.getEndTime()); + } + @Test + public void inPlaceSoftwareUpdate() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/inPlaceSoftwareUpdate"; + ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void inPlaceSoftwareUpdateDuplicate() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/VnfInPlaceUpdate")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + InfraActiveRequests req = new InfraActiveRequests(); + req.setRequestStatus("IN_PROGRESS"); + req.setAction("inPlaceSoftwareUpdate"); + req.setProgress(new Long(10)); + req.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); + req.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7908"); + req.setVnfId("ff305d54-75b4-431b-adb2-eb6b9e5ff033"); + req.setRequestScope("vnf"); + req.setVnfName("duplicateCheck123"); + req.setRequestAction("inPlaceSoftwareUpdate"); + req.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + iar.save(req); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7908/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff033/inPlaceSoftwareUpdate"; + ResponseEntity<String> response = sendRequest(inputStream("/InPlaceSoftwareUpdate2.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatusCode().value()); + + InfraActiveRequests newRecord = iar.findOneByRequestBody(inputStream("/InPlaceSoftwareUpdate2.json")); + + assertNotNull(newRecord.getServiceInstanceId()); + assertNotNull(newRecord.getVnfId()); + + } + + @Test + public void deleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/DeleteVfModule.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deactivateAndCloudDeleteVfModuleInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/vfModules/ff305d54-75b4-431b-adb2-eb6b9e5ff000/deactivateAndCloudDelete"; + ResponseEntity<String> response = sendRequest(inputStream("/DeactivateAndCloudDeleteVfModule.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups"; + ResponseEntity<String> response = sendRequest(inputStream("/VolumeGroup.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertTrue(response.getBody().contains("1882939")); + } + @Test + public void updateVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/UpdateVolumeGroup.json"), uri, HttpMethod.PUT); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deleteVolumeGroupInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7968/vnfs/ff305d54-75b4-431b-adb2-eb6b9e5ff000/volumeGroups/ff305d54-75b4-431b-adb2-eb6b9e5ff000"; + ResponseEntity<String> response = sendRequest(inputStream("/DeleteVolumeGroup.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void createNetworkInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + String requestId = "b7a6b76f-2ee2-416c-971b-548472a8c5c4"; + headers.set(MsoLogger.ONAP_REQUEST_ID, requestId); + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreate.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + InfraActiveRequests record = iar.findOneByRequestId(requestId); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertEquals(record.getNetworkType(), "TestNetworkType"); + } + @Test + public void updateNetworkInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity<String> response = sendRequest(inputStream("/UpdateNetwork.json"), uri, HttpMethod.PUT); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertTrue(response.getBody().contains("1882939")); + } + @Test + public void deleteNetworkInstance() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstance.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void deleteNetworkInstanceNoReqParams() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkInstanceNoReqParams.json"), uri, HttpMethod.DELETE); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + @Test + public void convertJsonToServiceInstanceRequestFail() throws JsonParseException, JsonMappingException, IOException { + headers.set(MsoLogger.ONAP_REQUEST_ID, "32807a28-1a14-4b88-b7b3-2950918aa76d"); + //ExpectedRecord + InfraActiveRequests expectedRecord = new InfraActiveRequests(); + expectedRecord.setRequestStatus("FAILED"); + expectedRecord.setStatusMessage("Error mapping request: "); + expectedRecord.setProgress(new Long(100)); + expectedRecord.setRequestBody(inputStream("/ConvertRequestFail.json")); + expectedRecord.setLastModifiedBy("APIH"); + expectedRecord.setRequestScope("network"); + expectedRecord.setRequestAction("deleteInstance"); + expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + + uri = servInstanceuri + "v6" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks/1710966e-097c-4d63-afda-e0d3bb7015fb"; + ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.DELETE); + + //ActualRecord + InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertThat(expectedRecord, sameBeanAs(requestRecord).ignoring("startTime").ignoring("endTime").ignoring("modifyTime").ignoring("statusMessage")); + assertThat(requestRecord.getStatusMessage(), containsString("Error mapping request: ")); + assertNotNull(requestRecord.getStartTime()); + assertNotNull(requestRecord.getEndTime()); + } + @Test + public void convertJsonToServiceInstanceRequestConfigurationFail() throws JsonParseException, JsonMappingException, IOException { + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/configurations/test/enablePort"; + ResponseEntity<String> response = sendRequest(inputStream("/ConvertRequestFail.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + } + + @Test + public void creatServiceInstanceGRTestApiNoCustomRecipeFound() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v7" + "/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceMacro.json"), uri, HttpMethod.POST); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void createNetworkInstanceTestApiUndefinedUsePropertiesDefault() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateAlternateInstanceName.json"), uri, HttpMethod.POST); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void createNetworkInstanceTestApiIncorrectUsePropertiesDefault() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiIncorrect.json"), uri, HttpMethod.POST); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + } + + @Test + public void createNetworkInstanceTestApiGrApi() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiGrApi.json"), uri, HttpMethod.POST); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void createNetworkInstanceTestApiVnfApi() throws IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/CreateNetworkInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v7" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7969/networks"; + ResponseEntity<String> response = sendRequest(inputStream("/NetworkCreateTestApiVnfApi.json"), uri, HttpMethod.POST); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void activateServiceInstanceRequestStatus() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/ActivateInstance")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + headers.set("X-ECOMP-RequestID", "32807a28-1a14-4b88-b7b3-2950918aa76d"); + + InfraActiveRequests expectedRecord = new InfraActiveRequests(); + expectedRecord.setRequestStatus("FAILED"); + expectedRecord.setAction("activateInstance"); + expectedRecord.setStatusMessage("Recipe could not be retrieved from catalog DB."); + expectedRecord.setProgress(new Long(100)); + expectedRecord.setSource("VID"); + expectedRecord.setRequestBody(inputStream("/ServiceInstanceALaCarteTrueNoRecipe.json")); + expectedRecord.setLastModifiedBy("APIH"); + expectedRecord.setServiceInstanceId("f7ce78bb-423b-11e7-93f8-0050569a7999"); + expectedRecord.setServiceInstanceName("testService1234"); + expectedRecord.setRequestScope("service"); + expectedRecord.setRequestAction("activateInstance"); + expectedRecord.setRequestorId("xxxxxx"); + expectedRecord.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + + //expect + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v5" + "/serviceInstances/f7ce78bb-423b-11e7-93f8-0050569a7999/activate"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstancePrev8.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + InfraActiveRequests requestRecord = iar.findOneByRequestId("32807a28-1a14-4b88-b7b3-2950918aa76d"); + + //then + assertEquals(Status.IN_PROGRESS.name(), requestRecord.getRequestStatus()); + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void invalidRequestId() throws IOException { + String illegalRequestId = "1234"; + headers.set("X-ECOMP-RequestID", illegalRequestId); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); + assertTrue(response.getBody().contains("Request Id " + illegalRequestId + " is not a valid UUID")); + } + @Test + public void invalidBPELResponse() throws IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponseInvalid2.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertEquals("Request Failed due to BPEL error with HTTP Status = 202{\"instanceId\": \"1882939\"}", realResponse.getServiceException().getText()); + } + + @Test + public void invalidBPELResponse2() throws IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponseInvalid.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + uri = servInstanceuri + "v5/serviceInstances"; + ResponseEntity<String> response = sendRequest(inputStream("/ServiceInstanceDefault.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class); + assertTrue(realResponse.getServiceException().getText().contains("<aetgt:ErrorMessage>Exception in create execution list 500")); + } + + @Test + public void createMacroServiceInstance() throws JsonParseException, JsonMappingException, IOException{ + stubFor(post(urlPathEqualTo("/mso/async/services/CreateMacroServiceNetworkVnf")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expect + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceUriPrev7 + "v5"; + ResponseEntity<String> response = sendRequest(inputStream("/MacroServiceInstance.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + //then + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + } + + @Test + public void testUserParams() throws JsonParseException, JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); + RequestParameters requestParameters = request.getRequestDetails().getRequestParameters(); + String userParamsTxt = inputStream("/userParams.txt"); + + List<Map<String, Object>> userParams = servInstances.configureUserParams(requestParameters); + System.out.println(userParams); + assertTrue(userParams.size() > 0); + assertTrue(userParams.get(0).containsKey("name")); + assertTrue(userParams.get(0).containsKey("value")); + assertTrue(userParamsTxt.replaceAll("\\s+","").equals(userParams.toString().replaceAll("\\s+",""))); + } + + @Test + public void testConfigureCloudConfig() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); + CloudConfiguration cloudConfig = servInstances.configureCloudConfig(request.getRequestDetails().getRequestParameters()); + + assertEquals("mdt25b", cloudConfig.getLcpCloudRegionId()); + assertEquals("aefb697db6524ddebfe4915591b0a347", cloudConfig.getTenantId()); + } + + @Test + public void testMapToLegacyRequest() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest request = mapper.readValue(inputStream("/MacroServiceInstance.json"), ServiceInstancesRequest.class); + ServiceInstancesRequest expected = mapper.readValue(inputStream("/LegacyMacroServiceInstance.json"), ServiceInstancesRequest.class); + servInstances.mapToLegacyRequest(request.getRequestDetails()); + System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(request)); + assertThat(request, sameBeanAs(expected)); + } + @Test + public void scaleOutVfModule() throws JsonParseException, JsonMappingException, IOException { + stubFor(post(urlPathEqualTo("/mso/async/services/WorkflowActionBB")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("Camunda/TestResponse.json").withStatus(org.apache.http.HttpStatus.SC_OK))); + + //expected response + ServiceInstancesResponse expectedResponse = new ServiceInstancesResponse(); + RequestReferences requestReferences = new RequestReferences(); + requestReferences.setInstanceId("1882939"); + expectedResponse.setRequestReferences(requestReferences); + uri = servInstanceuri + "v7" + "/serviceInstances/7a88cbeb-0ec8-4765-a271-4f9e90c3da7b/vnfs/cbba721b-4803-4df7-9347-307c9a955426/vfModules/scaleOut"; + ResponseEntity<String> response = sendRequest(inputStream("/ScaleOutRequest.json"), uri, HttpMethod.POST); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); + ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class); + assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId")); + assertTrue(response.getBody().contains("1882939")); + } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json index 18b785cae5..57aea4d2bb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudConfiguration.json @@ -32,7 +32,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json index bd114f7ad8..e876711c66 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateCloudRegionId.json @@ -35,7 +35,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json new file mode 100644 index 0000000000..1cc91500f0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/ScaleOutNoCloudConfig.json @@ -0,0 +1,50 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json new file mode 100644 index 0000000000..2f3f42e135 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ConfigurationParameters/NoConfigurationParameters.json @@ -0,0 +1,54 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json new file mode 100644 index 0000000000..d1220ad949 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelCustomizationId.json @@ -0,0 +1,53 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json new file mode 100644 index 0000000000..9447250ef6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelInvariantId.json @@ -0,0 +1,53 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json new file mode 100644 index 0000000000..ca60ffcf41 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelName.json @@ -0,0 +1,53 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json new file mode 100644 index 0000000000..b9914d374b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersion.json @@ -0,0 +1,53 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json new file mode 100644 index 0000000000..b4afcda4cf --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionId.json @@ -0,0 +1,53 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json new file mode 100644 index 0000000000..b9914d374b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/ModelInfo/ScaleOutNoModelVersionVersion.json @@ -0,0 +1,53 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "requestInfo": { + "instanceName": "MSO-DEV-VF-1806BB-vSAMP10a-base-it2-1", + "source": "VID", + "suppressRollback": false, + "requestorId": "xxxxxx" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json new file mode 100644 index 0000000000..47f49a728a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ScaleOutNoRelatedInstances.json @@ -0,0 +1,34 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vfModule", + "modelInvariantId":"ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelCustomizationId":"cb82ffd8-252a-11e7-93ae-92361f002672", + "modelName":"vSAMP12..base..module-0", + "modelVersion":"1" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "instanceName":"MSOTEST103a-vSAMP12_base_module-0", + "source":"VID", + "suppressRollback":true, + "requestorId":"xxxxxx" + }, + "requestParameters":{ + "usePreload":true, + "userParams":[ + + ] + }, + "configurationParameters":[ + { + "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json index b1c9e65bba..c917a9504e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/v6VnfDeleteInstance.json @@ -36,7 +36,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json index 484f7bfc97..39cba3cfc8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestInfo.json @@ -29,7 +29,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json index 8562be02b8..dbf47112f3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/RequestorId.json @@ -35,7 +35,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json new file mode 100644 index 0000000000..d403cc2af9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestInfo/ScaleOutNoRequestInfo.json @@ -0,0 +1,48 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "vfModule", + "modelName": "vSAMP10aDEV::base::module-0", + "modelVersionId": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantId": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationId": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mtn6", + "tenantId": "0422ffb57ba042c0800a29dc85ca70f8" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo": { + "modelType": "service", + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelVersionId": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantId": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + } + } + }, + { + "relatedInstance": { + "instanceId": "cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo": { + "modelType": "vnf", + "modelName": "vSAMP10a", + "modelVersionId": "d40be095-940e-4738-a72a-59aa9eb5671e", + "modelInvariantId": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationId": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelCustomizationName": "vSAMP10a 1" + } + } + } + ], + "requestParameters": { + "usePreload": true, + "userParams": [] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json index 476b9367c1..9a21a23ca0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/SuccessfulValidation/ServiceInPlaceSoftwareUpdate.json @@ -36,7 +36,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json new file mode 100644 index 0000000000..ba5a8a92e5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ScaleOutRequest.json @@ -0,0 +1,71 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelType":"vfModule", + "modelInvariantId":"ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelCustomizationId":"cb82ffd8-252a-11e7-93ae-92361f002672", + "modelName":"vSAMP12..base..module-0", + "modelVersion":"1" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"mdt1", + "tenantId":"88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo":{ + "instanceName":"MSOTEST103a-vSAMP12_base_module-0", + "source":"VID", + "suppressRollback":true, + "requestorId":"xxxxxx" + }, + "relatedInstanceList":[ + { + "relatedInstance":{ + "instanceId":"cbba721b-4803-4df7-9347-307c9a955426", + "instanceName":"MSOTESTVOL103a-vSAMP12_base_module-0_vol", + "modelInfo":{ + "modelType":"volumeGroup" + } + } + }, + { + "relatedInstance":{ + "instanceId":"7a88cbeb-0ec8-4765-a271-4f9e90c3da7b", + "modelInfo":{ + "modelType":"service", + "modelInvariantId":"ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName":"{parent service model name}", + "modelVersion":"1.0" + } + } + }, + { + "relatedInstance":{ + "instanceId":"cbba721b-4803-4df7-9347-307c9a955426", + "modelInfo":{ + "modelType":"vnf", + "modelInvariantId":"ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelVersionId":"fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName":"vSAMP12", + "modelVersion":"1.0", + "modelCustomizationName":"vSAMP12 1", + "modelCustomizationId":"a7f1d08e-b02d-11e6-80f5-76304dec7eb7" + } + } + } + ], + "requestParameters":{ + "usePreload":true, + "userParams":[ + + ] + }, + "configurationParameters":[ + { + "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]", + "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]" + } + ] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml index c5b3b70723..b7b6a8c1cb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml @@ -29,7 +29,7 @@ mso: catalog: db: spring: - endpoint: "http://localhost:" + endpoint: http://localhost:${wiremock.server.port} db: auth: Basic YnBlbDptc28tZGItMTUwNyE= config: diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql index 54984eeabb..70c0791055 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/data.sql @@ -224,8 +224,7 @@ INSERT INTO vnf_components_recipe(ID, VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, SERV ('19', 'vfModule', 'vfModule', 'createInstance', '', '1', 'VID_DEFAULT recipe to create vf-module if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleInfra', '', '180', '2016-09-14 19:18:20', '20c4431c-246d-11e7-93ae-92361f002672'), ('20', 'vfModule', 'vfModule', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete vf-module if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), ('21', 'vfModule', 'vfModule', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update vf-module if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('25', 'vfModule', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT'); - +('25', 'vfModule', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT'); INSERT INTO catalogdb.network_recipe(ID, MODEL_NAME, ACTION, DESCRIPTION, ORCHESTRATION_URI, NETWORK_PARAM_XSD, RECIPE_TIMEOUT, SERVICE_TYPE, CREATION_TIMESTAMP, VERSION_STR) VALUES ('17', 'VID_DEFAULT', 'createInstance', 'VID_DEFAULT recipe to create network if no custom BPMN flow is found', '/mso/async/services/CreateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), @@ -274,7 +273,9 @@ VALUES ('vfModule', 'deleteInstance', '1', 'Gr api recipe to delete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'), ('vfModule', 'updateInstance', '1', 'Gr api recipe to update vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'), ('vfModule', 'replaceInstance', '1', 'Gr api recipe to replace vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'), -('vfModule', 'deactivateAndCloudDelete', '1', 'Gr api recipe to deactivateAndCloudDelete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'); +('vfModule', 'deactivateAndCloudDelete', '1', 'Gr api recipe to deactivateAndCloudDelete vf-module', '/mso/async/services/WorkflowActionBB', 180, 'GR-API-DEFAULT'), +('vfModule', 'scaleOut', '1', 'Gr api recipe to scale out vfModule', '/mso/async/services/WorkflowActionBB', '180', 'GR-API-DEFAULT'); + UPDATE vnf_components_recipe SET vf_module_model_uuid = 'VNF-API-DEFAULT' diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml index 1b3a7cc6da..4da57a15f9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/logback-test.xml @@ -1,39 +1,41 @@ -<configuration > - - - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n +<configuration> + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n </pattern> - </encoder> - </appender> - <appender name="test" class="org.onap.so.apihandlerinfra.TestAppender"/> - - - <logger name="AUDIT" level="info" additivity="false"> - <appender-ref ref="STDOUT" /> - <appender-ref ref = "test" /> - </logger> - - <logger name="com.att.eelf.metrics" level="info" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> - - <logger name="com.att.eelf.error" level="ERROR" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> - - <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + </encoder> + </appender> + <appender name="test" class="org.onap.so.apihandlerinfra.TestAppender" /> + + + <logger name="AUDIT" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="ERROR" additivity="false"> <appender-ref ref="STDOUT" /> </logger> - - <logger name="com.att" level="${so.log.level:-DEBUG}" additivity="false"> - <appender-ref ref="STDOUT" /> - </logger> - <root level="WARN"> - <appender-ref ref="STDOUT" /> - </root> - - <logger name="wiremock.org" level="ERROR" /> + + <logger name="org.onap" level="${so.log.level:-DEBUG}" + additivity="false"> + <appender-ref ref="STDOUT" /> + <appender-ref ref="test" /> + </logger> + + <logger name="com.att" level="${so.log.level:-DEBUG}" + additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="wiremock.org" level="ERROR" /> </configuration>
\ No newline at end of file |