use of org.wso2.carbon.apimgt.core.workflow.Workflow in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImpl method retrieveUncompletedWorkflowsByType.
@Override
public List<Workflow> retrieveUncompletedWorkflowsByType(String type) throws APIManagementException {
if (log.isDebugEnabled()) {
log.debug("Requesting for uncompleted workflow information for type: " + type);
}
if (type == null) {
String message = "Error while retrieving workflow information. Missing workflow type";
log.error(message);
throw new APIManagementException(message, ExceptionCodes.WORKFLOW_RETRIEVE_EXCEPTION);
}
try {
return workflowDAO.retrieveUncompleteWorkflows(type);
} catch (APIMgtDAOException e) {
String message = "Error while retrieving workflow information";
log.error(message, e);
throw new APIManagementException(message, ExceptionCodes.APIMGT_DAO_EXCEPTION);
}
}
use of org.wso2.carbon.apimgt.core.workflow.Workflow in project carbon-apimgt by wso2.
the class WorkflowDAOIT method testGetExternalWorkflowReferenceForAPIStateChange.
@Test
public void testGetExternalWorkflowReferenceForAPIStateChange() throws Exception {
WorkflowDAO workflowDAO = DAOFactory.getWorkflowDAO();
String workflowExtRefId = UUID.randomUUID().toString();
String apiId = UUID.randomUUID().toString();
Workflow workflow = SampleTestObjectCreator.createWorkflow(workflowExtRefId);
workflow.setWorkflowReference(apiId);
workflow.setStatus(WorkflowStatus.CREATED);
workflow.setWorkflowType(WorkflowConstants.WF_TYPE_AM_API_STATE);
workflowDAO.addWorkflowEntry(workflow);
Optional<String> externalRefFromDb = workflowDAO.getExternalWorkflowReferenceForPendingTask(apiId, WorkflowConstants.WF_TYPE_AM_API_STATE);
if (externalRefFromDb.isPresent()) {
Assert.assertEquals(externalRefFromDb.get(), workflowExtRefId);
} else {
Assert.fail("External workflow reference does not exist");
}
}
use of org.wso2.carbon.apimgt.core.workflow.Workflow 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.workflow.Workflow 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.workflow.Workflow 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);
}
}
Aggregations