Search in sources :

Example 6 with SubscriptionCreationWorkflow

use of org.wso2.carbon.apimgt.core.workflow.SubscriptionCreationWorkflow in project carbon-apimgt by wso2.

the class WorkflowMappingUtilTest method testToWorkflowListDTO.

@Test(description = "Convert List<Workflow> workflowList to WorkflowListDTO")
public void testToWorkflowListDTO() throws Exception {
    List<Workflow> wfList = new ArrayList<>();
    Workflow workflow1 = new ApplicationCreationWorkflow(null, null, null);
    workflow1.setStatus(WorkflowStatus.APPROVED);
    LocalDateTime date1 = LocalDateTime.now();
    workflow1.setCreatedTime(date1);
    workflow1.setWorkflowDescription("Description 1");
    workflow1.setWorkflowType(WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
    String ref1 = UUID.randomUUID().toString();
    workflow1.setExternalWorkflowReference(ref1);
    wfList.add(workflow1);
    Workflow workflow2 = new SubscriptionCreationWorkflow(null, null, null);
    workflow2.setStatus(WorkflowStatus.APPROVED);
    LocalDateTime date2 = LocalDateTime.now();
    workflow2.setCreatedTime(date2);
    workflow2.setWorkflowDescription("Description 2");
    workflow2.setWorkflowType(WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
    String ref2 = UUID.randomUUID().toString();
    workflow2.setExternalWorkflowReference(ref2);
    wfList.add(workflow2);
    WorkflowListDTO wfDtoList = WorkflowMappingUtil.toWorkflowListDTO(wfList);
    int count = wfDtoList.getCount();
    Assert.assertEquals(count, 2, "Mismatch in the workflow list item count");
    Assert.assertEquals(wfDtoList.getList().get(0).getDescription(), "Description 1", "Invalid description for workflow item 1");
    Assert.assertEquals(wfDtoList.getList().get(0).getType(), WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION, "Invalid type for workflow item 1");
    Assert.assertEquals(wfDtoList.getList().get(0).getWorkflowStatus(), WorkflowStatus.APPROVED.toString(), "Invalid status for workflow item 1");
    Assert.assertEquals(wfDtoList.getList().get(0).getReferenceId(), ref1, "Invalid reference id for workflow item 1");
    Assert.assertEquals(wfDtoList.getList().get(1).getDescription(), "Description 2", "Invalid description for workflow item 2");
    Assert.assertEquals(wfDtoList.getList().get(1).getType(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION, "Invalid type for workflow item 2");
    Assert.assertEquals(wfDtoList.getList().get(1).getWorkflowStatus(), WorkflowStatus.APPROVED.toString(), "Invalid status for workflow item 2");
    Assert.assertEquals(wfDtoList.getList().get(1).getReferenceId(), ref2, "Invalid reference id for workflow item 2");
}
Also used : LocalDateTime(java.time.LocalDateTime) SubscriptionCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.SubscriptionCreationWorkflow) ArrayList(java.util.ArrayList) SubscriptionCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.SubscriptionCreationWorkflow) ApplicationCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) ApplicationCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow) WorkflowListDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowListDTO) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)4 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)4 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)3 WorkflowExecutor (org.wso2.carbon.apimgt.core.api.WorkflowExecutor)3 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)3 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)3 SubscriptionCreationWorkflow (org.wso2.carbon.apimgt.core.workflow.SubscriptionCreationWorkflow)3 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)2 API (org.wso2.carbon.apimgt.core.models.API)2 Application (org.wso2.carbon.apimgt.core.models.Application)2 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)2 SubscriptionResponse (org.wso2.carbon.apimgt.core.models.SubscriptionResponse)2 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)2 ApplicationCreationWorkflow (org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow)2 Workflow (org.wso2.carbon.apimgt.core.workflow.Workflow)2 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 BeforeTest (org.testng.annotations.BeforeTest)1 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)1 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)1