aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java135
1 files changed, 55 insertions, 80 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 321ea3ac7d..f82f5ac746 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -42,12 +42,12 @@ import java.util.Map;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudRequestData;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.Request;
@@ -119,7 +119,7 @@ public class OrchestrationRequestsTest extends BaseTest {
assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("00032ab7-na18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
+ assertEquals("00032ab7-1a18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
assertNotNull(response.getBody().getRequest().getFinishTime());
}
@@ -149,12 +149,22 @@ public class OrchestrationRequestsTest extends BaseTest {
}
@Test
- public void testGetOrchestrationRequestRequestDetails() throws Exception {
- setupTestGetOrchestrationRequestRequestDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
+ public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
+ setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
// Test request with modelInfo request body
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
+ List<CloudRequestData> cloudRequestData = new ArrayList<>();
+ CloudRequestData cloudData = new CloudRequestData();
+ cloudData.setCloudIdentifier("heatstackName/123123");
+ ObjectMapper mapper = new ObjectMapper();
+ Object reqData = mapper.readValue(
+ "{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ Object.class);
+ cloudData.setCloudRequest(reqData);
+ cloudRequestData.add(cloudData);
+ request.setCloudRequestData(cloudRequestData);
testResponse.setRequest(request);
String testRequestId = request.getRequestId();
@@ -163,13 +173,14 @@ public class OrchestrationRequestsTest extends BaseTest {
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
+ "/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
ResponseEntity<GetOrchestrationResponse> response =
restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
+ System.out.println("Response :" + response.getBody().toString());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
.ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
@@ -194,6 +205,29 @@ public class OrchestrationRequestsTest extends BaseTest {
}
@Test
+ public void testGetOrchestrationRequestInvalidRequestID() throws Exception {
+ setupTestGetOrchestrationRequest();
+ // TEST INVALID REQUESTID
+ GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
+
+ Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
+ testResponse.setRequest(request);
+ String testRequestId = "00032ab7-pfb3-42e5-965d-8ea592502016";
+ HttpHeaders headers = new HttpHeaders();
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+ headers.set("Content-Type", MediaType.APPLICATION_JSON);
+ HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
+
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
+
+ ResponseEntity<GetOrchestrationResponse> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
+
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
+ }
+
+ @Test
public void testGetOrchestrationRequestFilter() throws Exception {
setupTestGetOrchestrationRequestFilter();
List<String> values = new ArrayList<>();
@@ -319,75 +353,11 @@ public class OrchestrationRequestsTest extends BaseTest {
"/onap/so/infra/orchestrationRequests/v7/" + "5ffbabd6-b793-4377-a1ab-082670fbc7ac" + "/unlock"));
response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
- // Cannot assert anything further here, already have a wiremock in place which ensures that the post was
+ // Cannot assert anything further here, already have a wiremock in place
+ // which ensures that the post was
// properly called to update.
}
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsWhiteSpace() throws Exception {
- InfraActiveRequests requests = new InfraActiveRequests();
- requests.setAction("create");
- requests.setRequestBody(" ");
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(requests);
-
- requestsDbClient.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- 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("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
-
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsAlaCarte() throws IOException {
- InfraActiveRequests requests = new InfraActiveRequests();
-
- String requestJSON = new String(
- Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/AlaCarteRequest.json")));
-
- requests.setAction("create");
- requests.setRequestBody(requestJSON);
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- // iar.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- 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("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
-
@Test
public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
RequestProcessingData entry = new RequestProcessingData();
@@ -423,14 +393,14 @@ public class OrchestrationRequestsTest extends BaseTest {
public void setupTestGetOrchestrationRequest() throws Exception {
// For testGetOrchestrationRequest
- wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(
Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
.withStatus(HttpStatus.SC_OK)));
wireMockServer
.stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
- .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
+ .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths
.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
@@ -439,14 +409,14 @@ public class OrchestrationRequestsTest extends BaseTest {
public void setupTestGetOrchestrationRequestInstanceGroup() throws Exception {
// For testGetOrchestrationRequest
- wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
+ wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get(
"src/test/resources/OrchestrationRequest/getOrchestrationRequestInstanceGroup.json"))))
.withStatus(HttpStatus.SC_OK)));
wireMockServer
.stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
- .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
+ .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-1a18-42e5-965d-8ea592502018"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths
.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
@@ -461,15 +431,20 @@ public class OrchestrationRequestsTest extends BaseTest {
.withStatus(HttpStatus.SC_OK)));
}
+ private void setupTestGetOrchestrationRequestOpenstackDetails(String requestId, String status) throws Exception {
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths
+ .get("src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json"))))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(String.format(getResponseTemplate, requestId, status)).withStatus(HttpStatus.SC_OK)));
-
}
-
-
private void setupTestUnlockOrchestrationRequest_invalid_Json() {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));