Search in sources :

Example 31 with WorkflowDAO

use of org.wso2.carbon.apimgt.core.dao.WorkflowDAO in project carbon-apimgt by wso2.

the class WorkflowDAOIT method testGetPendinExternalWorkflowReferenceForApprovedasks.

@Test
public void testGetPendinExternalWorkflowReferenceForApprovedasks() throws Exception {
    WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
    String workflowExtRefId = UUID.randomUUID().toString();
    String applicationId = UUID.randomUUID().toString();
    Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowExtRefId);
    workflow.setWorkflowType(WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
    workflow.setWorkflowReference(applicationId);
    workflow.setStatus(WorkflowStatus.APPROVED);
    workflowDAO.addWorkflowEntry(workflow);
    Optional<String> externalRefFromDb = workflowDAO.getExternalWorkflowReferenceForPendingTask(applicationId, WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
    Assert.assertFalse(externalRefFromDb.isPresent(), "Should return only if the wf task is in CREATED state");
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) Test(org.testng.annotations.Test)

Example 32 with WorkflowDAO

use of org.wso2.carbon.apimgt.core.dao.WorkflowDAO in project carbon-apimgt by wso2.

the class WorkflowDAOIT method testGetExternalWorkflowReferenceForSubscription.

@Test
public void testGetExternalWorkflowReferenceForSubscription() throws Exception {
    WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
    String workflowExtRefId = UUID.randomUUID().toString();
    String subscriptionId = UUID.randomUUID().toString();
    Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowExtRefId);
    workflow.setWorkflowType(WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
    workflow.setWorkflowReference(subscriptionId);
    workflow.setStatus(WorkflowStatus.CREATED);
    workflowDAO.addWorkflowEntry(workflow);
    Optional<String> externalRefFromDb = workflowDAO.getExternalWorkflowReferenceForPendingTask(subscriptionId, WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
    if (externalRefFromDb.isPresent()) {
        Assert.assertEquals(externalRefFromDb.get(), workflowExtRefId);
    } else {
        Assert.fail("External workflow reference does not exist");
    }
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) Test(org.testng.annotations.Test)

Example 33 with WorkflowDAO

use of org.wso2.carbon.apimgt.core.dao.WorkflowDAO in project carbon-apimgt by wso2.

the class WorkflowDAOIT method testUpdateWorkflowStatusWithoutAddingEntry.

@Test
public void testUpdateWorkflowStatusWithoutAddingEntry() throws Exception {
    WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
    String workflowRefId = UUID.randomUUID().toString();
    Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowRefId);
    workflow.setStatus(WorkflowStatus.APPROVED);
    workflow.setUpdatedTime(LocalDateTime.now());
    workflowDAO.updateWorkflowStatus(workflow);
    // Workflow entry should not be in the db. so exception should be thrown
    try {
        workflowDAO.retrieveWorkflow(workflow.getExternalWorkflowReference());
        // should throw exception.
        Assert.fail("Expected exception is not thrown when entry is not in the DB");
    } catch (APIMgtDAOException e) {
        Assert.assertEquals(e.getErrorHandler(), ExceptionCodes.WORKFLOW_NOT_FOUND);
    }
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) Test(org.testng.annotations.Test)

Example 34 with WorkflowDAO

use of org.wso2.carbon.apimgt.core.dao.WorkflowDAO in project carbon-apimgt by wso2.

the class WorkflowDAOIT method testremoveWorkflowEntry.

@Test
public void testremoveWorkflowEntry() throws Exception {
    String workflowRefId = UUID.randomUUID().toString();
    WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
    Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowRefId);
    workflowDAO.addWorkflowEntry(workflow);
    workflowDAO.deleteWorkflowEntryforExternalReference(workflow.getExternalWorkflowReference());
    // Workflow entry should not be in the db. so exception should be thrown
    try {
        workflowDAO.retrieveWorkflow(workflow.getExternalWorkflowReference());
        // should throw exception.
        Assert.fail("Expected exception is not thrown when entry is not in the DB");
    } catch (APIMgtDAOException e) {
        Assert.assertEquals(e.getErrorHandler(), ExceptionCodes.WORKFLOW_NOT_FOUND);
    }
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) Test(org.testng.annotations.Test)

Example 35 with WorkflowDAO

use of org.wso2.carbon.apimgt.core.dao.WorkflowDAO in project carbon-apimgt by wso2.

the class WorkflowDAOIT method testAddWorkflowEntry.

@Test
public void testAddWorkflowEntry() throws Exception {
    String workflowRefId = UUID.randomUUID().toString();
    WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
    Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowRefId);
    workflowDAO.addWorkflowEntry(workflow);
    Workflow retrieveWorflow = workflowDAO.retrieveWorkflow(workflow.getExternalWorkflowReference());
    Assert.assertEquals(retrieveWorflow.getExternalWorkflowReference(), workflowRefId);
    Assert.assertEquals(retrieveWorflow.getStatus(), workflow.getStatus());
    Assert.assertEquals(retrieveWorflow.getWorkflowReference(), workflow.getWorkflowReference());
    Assert.assertEquals(retrieveWorflow.getAttributes(), workflow.getAttributes());
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) Test(org.testng.annotations.Test)

Aggregations

WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)43 Test (org.testng.annotations.Test)42 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)29 ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)21 BeforeTest (org.testng.annotations.BeforeTest)19 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)19 Application (org.wso2.carbon.apimgt.core.models.Application)18 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)15 API (org.wso2.carbon.apimgt.core.models.API)15 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)14 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)14 Workflow (org.wso2.carbon.apimgt.core.workflow.Workflow)14 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)12 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)11 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)11 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)11 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)8 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)5 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)5 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)5