Search in sources :

Example 1 with RequestStatus

use of org.onap.so.serviceinstancebeans.RequestStatus in project so by onap.

the class OrchestrationRequestsUnitTest method taskNameLookup.

@Test
public void taskNameLookup() throws ContactCamundaException {
    InfraActiveRequests req = new InfraActiveRequests();
    req.setRequestId("70debc2a-d6bc-4795-87ba-38a94d9b0b99");
    Instant startInstant = Instant.now().minus(1, ChronoUnit.DAYS);
    req.setStartTime(Timestamp.from(startInstant));
    when(env.getProperty("mso.camundaCleanupInterval")).thenReturn(null);
    when(camundaRequestHandler.getTaskName("70debc2a-d6bc-4795-87ba-38a94d9b0b99")).thenReturn("taskName");
    RequestStatus requestStatus = new RequestStatus();
    req.setFlowStatus("Building blocks 1 of 3 completed.");
    orchestrationRequests.mapRequestStatusAndExtSysErrSrcToRequest(req, requestStatus, null, "v7");
    assertEquals("FLOW STATUS: Building blocks 1 of 3 completed. TASK INFORMATION: taskName", requestStatus.getStatusMessage());
}
Also used : Instant(java.time.Instant) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 2 with RequestStatus

use of org.onap.so.serviceinstancebeans.RequestStatus in project so by onap.

the class OrchestrationRequestsUnitTest method mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest.

@Test
public void mapRequestStatusAndExtSysErrSrcToRequestFlowStatusSuccessfulCompletionTest() throws ApiException {
    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", "Successfully completed all Building Blocks", 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;
    iar.setFlowStatus("Successfully completed all Building Blocks");
    Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, OrchestrationRequestFormat.DETAIL.toString(), "v7");
    assertThat(actual, 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 3 with RequestStatus

use of org.onap.so.serviceinstancebeans.RequestStatus 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));
}
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 4 with RequestStatus

use of org.onap.so.serviceinstancebeans.RequestStatus in project so by onap.

the class OrchestrationRequestsUnitTest method requestStatusExtSystemErrorSourceTest.

@Test
public void requestStatusExtSystemErrorSourceTest() {
    RequestStatus requestStatus = new RequestStatus();
    requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE);
    assertThat(requestStatus.getExtSystemErrorSource(), is(equalTo(EXT_SYSTEM_ERROR_SOURCE)));
}
Also used : RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Example 5 with RequestStatus

use of org.onap.so.serviceinstancebeans.RequestStatus in project so by onap.

the class OrchestrationRequestsUnitTest method noCamundaLookupAfterInterval.

@Test
public void noCamundaLookupAfterInterval() throws ContactCamundaException {
    InfraActiveRequests req = new InfraActiveRequests();
    req.setRequestId("70debc2a-d6bc-4795-87ba-38a94d9b0b99");
    Instant startInstant = Instant.now().minus(36, ChronoUnit.DAYS);
    req.setStartTime(Timestamp.from(startInstant));
    when(env.getProperty("mso.camundaCleanupInterval")).thenReturn("35");
    RequestStatus requestStatus = new RequestStatus();
    req.setFlowStatus("Building blocks 1 of 3 completed.");
    orchestrationRequests.mapRequestStatusAndExtSysErrSrcToRequest(req, requestStatus, null, "v7");
    assertEquals("FLOW STATUS: Building blocks 1 of 3 completed.", requestStatus.getStatusMessage());
}
Also used : Instant(java.time.Instant) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) RequestStatus(org.onap.so.serviceinstancebeans.RequestStatus) Test(org.junit.Test)

Aggregations

RequestStatus (org.onap.so.serviceinstancebeans.RequestStatus)17 Test (org.junit.Test)16 SimpleDateFormat (java.text.SimpleDateFormat)14 InstanceReferences (org.onap.so.serviceinstancebeans.InstanceReferences)14 Request (org.onap.so.serviceinstancebeans.Request)14 Instant (java.time.Instant)2 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)1 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)1 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 ValidationException (org.onap.so.exceptions.ValidationException)1 CloudRequestData (org.onap.so.serviceinstancebeans.CloudRequestData)1 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)1 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)1