use of org.wso2.carbon.apimgt.core.workflow.Workflow 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.workflow.Workflow 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());
}
use of org.wso2.carbon.apimgt.core.workflow.Workflow in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testAddSubscription.
@Test(description = "Add subscription to an application")
public void testAddSubscription() throws APIManagementException {
ApplicationDAO applicationDAO = Mockito.mock(ApplicationDAO.class);
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
WorkflowDAO workflowDAO = Mockito.mock(WorkflowDAO.class);
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
Policy policy = new SubscriptionPolicy(UUID, TIER);
Mockito.when(policyDAO.getSimplifiedPolicyByLevelAndName(APIMgtAdminService.PolicyLevel.subscription, TIER)).thenReturn(policy);
APIStore apiStore = getApiStoreImpl(apiDAO, applicationDAO, apiSubscriptionDAO, workflowDAO, apiGateway, policyDAO);
API.APIBuilder apiBuilder = SampleTestObjectCreator.createDefaultAPI();
apiBuilder.lifeCycleStatus(APIStatus.PUBLISHED.getStatus());
API api = apiBuilder.build();
String apiId = api.getId();
Application application = new Application("TestApp", USER_ID);
application.setId(UUID);
Mockito.when(apiDAO.getAPI(apiId)).thenReturn(api);
Mockito.when(applicationDAO.getApplication(UUID)).thenReturn(application);
SubscriptionResponse subscriptionResponse = apiStore.addApiSubscription(apiId, UUID, TIER);
String subscriptionId = subscriptionResponse.getSubscriptionUUID();
Assert.assertNotNull(subscriptionId);
// before workflow add subscription with blocked state
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).addAPISubscription(subscriptionId, apiId, UUID, policy.getUuid(), APIMgtConstants.SubscriptionStatus.ON_HOLD);
// after workflow change the state
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).updateSubscriptionStatus(subscriptionId, APIMgtConstants.SubscriptionStatus.ACTIVE);
}
use of org.wso2.carbon.apimgt.core.workflow.Workflow in project carbon-apimgt by wso2.
the class TestMappingUtilTestCase method testWorkflowResponseToWorkflowResponseDTOMapping.
@Test(description = "Workflow response to Workflow response DTO mapping ")
void testWorkflowResponseToWorkflowResponseDTOMapping() {
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(WorkflowStatus.APPROVED);
WorkflowResponseDTO workflowResponseDTO = MappingUtil.toWorkflowResponseDTO(workflowResponse);
assertEquals(workflowResponse.getWorkflowStatus().name(), workflowResponseDTO.getWorkflowStatus().name());
}
Aggregations