summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/E2EServiceInstancesTest.java120
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml2
2 files changed, 79 insertions, 43 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/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: