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");
}
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");
}
}
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);
}
}
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);
}
}
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());
}
Aggregations