Search in sources :

Example 91 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class WorkflowActionBBFailureTest method updateRequestStatusToRolledbackToCreated.

@Test
public void updateRequestStatusToRolledbackToCreated() {
    execution.setVariable("mso-request-id", "123");
    execution.setVariable("isRollbackComplete", true);
    execution.setVariable("isRollback", true);
    execution.setVariable("rollbackTargetState", "ROLLED_BACK_TO_CREATED");
    InfraActiveRequests req = new InfraActiveRequests();
    doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
    doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
    workflowActionBBFailure.updateRequestStatusToFailed(execution);
    String errorMsg = (String) execution.getVariable("RollbackErrorMessage");
    assertEquals("Rollback has been completed successfully.", errorMsg);
    assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), req.getRequestStatus());
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 92 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class WorkflowActionBBFailureTest method updateRequestStatusToFailed.

@Test
public void updateRequestStatusToFailed() {
    execution.setVariable("mso-request-id", "123");
    execution.setVariable("isRollbackComplete", false);
    execution.setVariable("isRollback", false);
    InfraActiveRequests req = new InfraActiveRequests();
    WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case");
    execution.setVariable("WorkflowException", wfe);
    doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
    doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
    workflowActionBBFailure.updateRequestStatusToFailed(execution);
    String errorMsg = (String) execution.getVariable("ErrorMessage");
    assertEquals("error in test case", errorMsg);
    assertEquals(Status.FAILED.toString(), req.getRequestStatus());
}
Also used : WorkflowException(org.onap.so.bpmn.core.WorkflowException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 93 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class WorkflowActionBBTasksTest method setConfigurationNameTest.

@Test
public void setConfigurationNameTest() {
    String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c";
    WorkflowType resourceType = WorkflowType.CONFIGURATION;
    InfraActiveRequests request = new InfraActiveRequests();
    Configuration configuration = new Configuration();
    configuration.setConfigurationName("configurationName");
    doReturn(configuration).when(bbSetupUtils).getAAIConfiguration(resourceId);
    workflowActionBBTasks.setInstanceName(resourceId, resourceType, request);
    assertEquals("configurationName", request.getConfigurationName());
}
Also used : Configuration(org.onap.aai.domain.yang.Configuration) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 94 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class WorkflowActionBBTasksTest method checkRetryStatusTest.

@Test
public void checkRetryStatusTest() {
    String reqId = "reqId123";
    execution.setVariable("mso-request-id", reqId);
    doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class));
    doReturn("6").when(environment).getProperty("mso.rainyDay.maxRetries");
    execution.setVariable("handlingCode", "Retry");
    execution.setVariable("retryCount", 1);
    execution.setVariable("gCurrentSequence", 1);
    InfraActiveRequests req = new InfraActiveRequests();
    doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
    workflowActionBBTasks.checkRetryStatus(execution);
    assertEquals(0, execution.getVariable("gCurrentSequence"));
}
Also used : DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 95 with InfraActiveRequests

use of org.onap.so.db.request.beans.InfraActiveRequests in project so by onap.

the class WorkflowActionBBTasksTest method updateRequestStatusToCompleteTest.

@Test
public void updateRequestStatusToCompleteTest() {
    String reqId = "reqId123";
    execution.setVariable("mso-request-id", reqId);
    execution.setVariable("requestAction", "createInstance");
    execution.setVariable("resourceName", "Service");
    execution.setVariable("aLaCarte", true);
    InfraActiveRequests req = new InfraActiveRequests();
    doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId);
    doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
    workflowActionBBTasks.updateRequestStatusToComplete(execution);
    assertEquals("ALaCarte-Service-createInstance request was executed correctly.", execution.getVariable("finalStatusMessage"));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Aggregations

InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)214 Test (org.junit.Test)119 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)29 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 Timestamp (java.sql.Timestamp)23 HttpEntity (org.springframework.http.HttpEntity)21 IOException (java.io.IOException)20 HashMap (java.util.HashMap)20 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)20 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)19 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)19 BaseTest (org.onap.so.apihandlerinfra.BaseTest)18 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)18 ArrayList (java.util.ArrayList)16 ValidationException (org.onap.so.exceptions.ValidationException)15 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)13 Transactional (javax.transaction.Transactional)13 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)11