use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequest.
@Test
public void testGetOrchestrationRequest() throws Exception {
setupTestGetOrchestrationRequest();
// TEST VALID REQUEST
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
testResponse.setRequest(request);
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);
String testRequestId = request.getRequestId();
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
headers.set(ONAPLogConstants.Headers.REQUEST_ID, "1e45215d-b7b3-4c5a-9316-65bdddaf649f");
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.OK.getStatusCode(), response.getStatusCode().value());
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
assertNull(response.getBody().getRequest().getInstanceReferences().getRequestorId());
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("1e45215d-b7b3-4c5a-9316-65bdddaf649f", response.getHeaders().get("X-TransactionID").get(0));
assertNotNull(response.getBody().getRequest().getFinishTime());
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsTest method getOrchestrationRequestSimpleTest.
@Test
public void getOrchestrationRequestSimpleTest() throws Exception {
setupTestGetOrchestrationRequest();
// TEST VALID REQUEST
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
request.setRequestProcessingData(null);
testResponse.setRequest(request);
String testRequestId = request.getRequestId();
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
headers.set(ONAPLogConstants.Headers.REQUEST_ID, "e5e3c007-9fe9-4a20-8691-bdd20e14504d");
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId)).queryParam("format", "simple");
ResponseEntity<GetOrchestrationResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
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("e5e3c007-9fe9-4a20-8691-bdd20e14504d", response.getHeaders().get("X-TransactionID").get(0));
assertNotNull(response.getBody().getRequest().getFinishTime());
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequestFilter.
@Test
public void testGetOrchestrationRequestFilter() throws Exception {
setupTestGetOrchestrationRequestFilter();
List<String> values = new ArrayList<>();
values.add("EQUALS");
values.add("vfModule");
ObjectMapper mapper = new ObjectMapper();
GetOrchestrationListResponse testResponse = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"), GetOrchestrationListResponse.class);
Map<String, List<String>> orchestrationMap = new HashMap<>();
orchestrationMap.put("modelType", values);
List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationListResponse.class);
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("requestList.request.startTime").ignoring("requestList.request.finishTime").ignoring("requestList.request.requestStatus.timeStamp"));
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
assertEquals(requests.size(), response.getBody().getRequestList().size());
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsUnitTest method mapInfraActiveRequestToRequestOriginalRequestIdNullTest.
@Test
public void mapInfraActiveRequestToRequestOriginalRequestIdNullTest() 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");
iar.setWorkflowName(WORKFLOW_NAME);
iar.setOperationName(OPERATION_NAME);
Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7");
assertThat(result, sameBeanAs(expected));
}
use of org.onap.so.serviceinstancebeans.Request in project so by onap.
the class OrchestrationRequestsUnitTest method mapInfraActiveRequestToRequestWithNoWorkflowNameAndNoOperationNameTest.
@Test
public void mapInfraActiveRequestToRequestWithNoWorkflowNameAndNoOperationNameTest() 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.setOriginalRequestId(ORIGINAL_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");
expected.setWorkflowName(REQUEST_ACTION);
expected.setRequestType(REQUEST_ACTION);
iar.setOriginalRequestId(ORIGINAL_REQUEST_ID);
iar.setRequestAction(REQUEST_ACTION);
iar.setWorkflowName(null);
iar.setOperationName(null);
Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v8");
assertThat(result, sameBeanAs(expected));
}
Aggregations