Search in sources :

Example 16 with Request

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());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) Request(org.onap.so.serviceinstancebeans.Request) ArrayList(java.util.ArrayList) GetOrchestrationResponse(org.onap.so.serviceinstancebeans.GetOrchestrationResponse) RequestProcessingData(org.onap.so.serviceinstancebeans.RequestProcessingData) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Test(org.junit.Test)

Example 17 with Request

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());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Request(org.onap.so.serviceinstancebeans.Request) GetOrchestrationResponse(org.onap.so.serviceinstancebeans.GetOrchestrationResponse) Test(org.junit.Test)

Example 18 with Request

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());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Request(org.onap.so.serviceinstancebeans.Request) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 19 with Request

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));
}
Also used : InstanceReferences(org.onap.so.serviceinstancebeans.InstanceReferences) Request(org.onap.so.serviceinstancebeans.Request) SimpleDateFormat(java.text.SimpleDateFormat) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 20 with Request

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));
}
Also used : InstanceReferences(org.onap.so.serviceinstancebeans.InstanceReferences) Request(org.onap.so.serviceinstancebeans.Request) SimpleDateFormat(java.text.SimpleDateFormat) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Aggregations

Request (org.onap.so.serviceinstancebeans.Request)25 Test (org.junit.Test)22 InstanceReferences (org.onap.so.serviceinstancebeans.InstanceReferences)15 SimpleDateFormat (java.text.SimpleDateFormat)14 RequestStatus (org.onap.so.serviceinstancebeans.RequestStatus)14 HttpEntity (org.springframework.http.HttpEntity)8 HttpHeaders (org.springframework.http.HttpHeaders)8 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)8 GetOrchestrationResponse (org.onap.so.serviceinstancebeans.GetOrchestrationResponse)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)3 ValidationException (org.onap.so.exceptions.ValidationException)3 GetOrchestrationListResponse (org.onap.so.serviceinstancebeans.GetOrchestrationListResponse)3 RequestProcessingData (org.onap.so.serviceinstancebeans.RequestProcessingData)3 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)3 Operation (io.swagger.v3.oas.annotations.Operation)2 IOException (java.io.IOException)2