use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUpdateSubscriptionStatus.
@Test(description = "Update subscription status")
public void testUpdateSubscriptionStatus() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIGateway apiGatewayPublisher = Mockito.mock(APIGateway.class);
Application application = SampleTestObjectCreator.createDefaultApplication();
API api = SampleTestObjectCreator.createDefaultAPI().build();
Policy policy = SampleTestObjectCreator.createDefaultSubscriptionPolicy();
Subscription subscription = new Subscription(SUB_ID, application, api, policy);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiSubscriptionDAO, apiGatewayPublisher);
Mockito.when(apiSubscriptionDAO.getAPISubscription(SUB_ID)).thenReturn(subscription);
apiPublisher.updateSubscriptionStatus(SUB_ID, APIMgtConstants.SubscriptionStatus.ACTIVE);
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).updateSubscriptionStatus(SUB_ID, APIMgtConstants.SubscriptionStatus.ACTIVE);
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testGetAPISubscriptions.
@Test(description = "Get api subscriptions")
public void testGetAPISubscriptions() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(apiSubscriptionDAO);
Mockito.when(apiSubscriptionDAO.getAPISubscriptionsOfAPIForValidation(LIMIT)).thenReturn(new ArrayList<>());
adminService.getAPISubscriptions(LIMIT);
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).getAPISubscriptionsOfAPIForValidation(LIMIT);
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class DefaultWorkflowExecutorTestCase method testWorkflowResponses.
@Test(description = "Test workflow responses")
public void testWorkflowResponses() throws WorkflowException {
WorkflowExecutor executor = new DefaultWorkflowExecutor();
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
WorkflowDAO workflowDAO = Mockito.mock(WorkflowDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
Workflow workflow = new SubscriptionCreationWorkflow(apiSubscriptionDAO, workflowDAO, apiGateway);
WorkflowResponse response = executor.execute(workflow);
Assert.assertEquals(response.getJSONPayload(), "");
Assert.assertEquals(response.getWorkflowStatus(), WorkflowStatus.APPROVED);
workflow.setStatus(WorkflowStatus.APPROVED);
response = executor.complete(workflow);
Assert.assertEquals(response.getWorkflowStatus(), WorkflowStatus.APPROVED);
executor.cleanUpPendingTask(workflow.getExternalWorkflowReference());
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUpdateSubscriptionPolicy.
@Test(description = "Update subscription policy")
public void testUpdateSubscriptionPolicy() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiSubscriptionDAO);
apiPublisher.updateSubscriptionPolicy(SUB_ID, "test policy");
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).updateSubscriptionPolicy(SUB_ID, "test policy");
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testUpdateSubscriptionPolicyException.
@Test(description = "Error when updating subscription policy", expectedExceptions = APIManagementException.class)
public void testUpdateSubscriptionPolicyException() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiSubscriptionDAO);
Mockito.doThrow(new APIMgtDAOException("", new Throwable())).when(apiSubscriptionDAO).updateSubscriptionPolicy(SUB_ID, "test policy");
apiPublisher.updateSubscriptionPolicy(SUB_ID, "test policy");
}
Aggregations