use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequestWithOpenstackDetails.
@Test
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();
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
data.add(data1);
e.setDataPairs(data);
testResponse.getRequest().getRequestProcessingData().add(e);
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
headers.set(ONAPLogConstants.Headers.REQUEST_ID, "0321e28d-3dde-4b31-9b28-1e0f07231b93");
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
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));
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("0321e28d-3dde-4b31-9b28-1e0f07231b93", response.getHeaders().get("X-TransactionID").get(0));
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsTest method testUnlockOrchestrationRequest_Valid_Status.
@Test
public void testUnlockOrchestrationRequest_Valid_Status() throws JsonParseException, JsonMappingException, IOException, ValidationException {
setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING");
String requestJSON = new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
UriComponentsBuilder builder;
ResponseEntity<String> response;
Request request;
// Test valid status
request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/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
// properly called to update.
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequestInvalidRequestID.
@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());
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsUnitTest method mapRequestStatusAndExtSysErrSrcToRequestNoFlowStatusTest.
@Test
public void mapRequestStatusAndExtSysErrSrcToRequestNoFlowStatusTest() throws ApiException {
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
requestStatus.setStatusMessage(String.format("RETRY STATUS: %s ROLLBACK STATUS: %s", RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
expected.setInstanceReferences(instanceReferences);
expected.setRequestStatus(requestStatus);
expected.setRequestScope(SERVICE);
expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
includeCloudRequest = false;
iar.setFlowStatus(null);
iar.setResourceStatusMessage(null);
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsUnitTest method mapRequestStatusAndExtSysErrSrcToRequestDetailTest.
@Test
public void mapRequestStatusAndExtSysErrSrcToRequestDetailTest() throws ApiException {
doReturn("Last task executed: Call SDNC").when(camundaRequestHandler).getTaskName(REQUEST_ID);
InstanceReferences instanceReferences = new InstanceReferences();
instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
RequestStatus requestStatus = new RequestStatus();
requestStatus.setRequestState(iar.getRequestStatus());
requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s RESOURCE STATUS: %s", FLOW_STATUS + TASK_INFORMATION, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE, "The vf module already exist"));
Request expected = new Request();
expected.setRequestId(REQUEST_ID);
expected.setInstanceReferences(instanceReferences);
expected.setRequestStatus(requestStatus);
expected.setRequestScope(SERVICE);
expected.setStartTime(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(startTime) + " GMT");
includeCloudRequest = false;
Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(actual, sameBeanAs(expected));
}
Aggregations