use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testDeleteSubscriptionWithOnholdState.
@Test(description = "Delete subscription with on_hold state")
public void testDeleteSubscriptionWithOnholdState() throws APIManagementException {
ApplicationDAO applicationDAO = Mockito.mock(ApplicationDAO.class);
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
WorkflowDAO workflowDAO = Mockito.mock(WorkflowDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIStore apiStore = getApiStoreImpl(applicationDAO, apiSubscriptionDAO, workflowDAO, apiGateway);
Application application = SampleTestObjectCreator.createDefaultApplication();
APIBuilder builder = SampleTestObjectCreator.createDefaultAPI();
API api = builder.build();
Subscription subscription = new Subscription(UUID, application, api, new SubscriptionPolicy("Gold"));
subscription.setStatus(SubscriptionStatus.ON_HOLD);
String externalRef = java.util.UUID.randomUUID().toString();
Mockito.when(workflowDAO.getExternalWorkflowReferenceForPendingTask(subscription.getId(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION)).thenReturn(Optional.of(externalRef));
Mockito.when(apiSubscriptionDAO.getAPISubscription(UUID)).thenReturn(subscription);
apiStore.deleteAPISubscription(UUID);
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).deleteAPISubscription(UUID);
Mockito.verify(workflowDAO, Mockito.times(1)).getExternalWorkflowReferenceForPendingTask(subscription.getId(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testDeleteSubscription.
@Test(description = "Delete subscription")
public void testDeleteSubscription() throws APIManagementException {
ApplicationDAO applicationDAO = Mockito.mock(ApplicationDAO.class);
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
WorkflowDAO workflowDAO = Mockito.mock(WorkflowDAO.class);
APIGateway apiGateway = Mockito.mock(APIGateway.class);
APIStore apiStore = getApiStoreImpl(applicationDAO, apiSubscriptionDAO, workflowDAO, apiGateway);
Application application = SampleTestObjectCreator.createDefaultApplication();
APIBuilder builder = SampleTestObjectCreator.createDefaultAPI();
API api = builder.build();
Subscription subscription = new Subscription(UUID, application, api, new SubscriptionPolicy("Gold"));
Mockito.when(apiSubscriptionDAO.getAPISubscription(UUID)).thenReturn(subscription);
apiStore.deleteAPISubscription(UUID);
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).deleteAPISubscription(UUID);
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class AbstractAPIManagerTestCase method testGetSubscriptionsByAPI.
@Test(description = "Getting subscriptions by API")
public void testGetSubscriptionsByAPI() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = mock(APISubscriptionDAO.class);
AbstractAPIManager apiStore = getAPIStoreImpl(apiSubscriptionDAO);
when(apiSubscriptionDAO.getAPISubscriptionsByAPI(UUID)).thenReturn(new ArrayList<Subscription>());
apiStore.getSubscriptionsByAPI(UUID);
verify(apiSubscriptionDAO, times(1)).getAPISubscriptionsByAPI(UUID);
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class APIPublisherImplTestCase method testGetSubscribersOfProvider.
@Test(description = "Get subscriptions for a provider's APIs")
public void testGetSubscribersOfProvider() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIPublisherImpl apiPublisher = getApiPublisherImpl(apiSubscriptionDAO);
Mockito.when(apiSubscriptionDAO.getAPISubscriptionsForUser(1, 2, USER)).thenReturn(new ArrayList<Subscription>());
apiPublisher.getSubscribersOfProvider(1, 2, USER);
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).getAPISubscriptionsForUser(1, 2, USER);
}
use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.
the class AbstractAPIManagerTestCase method testGetSubscriptionByUUID.
@Test(description = "Get subscription by UUID")
public void testGetSubscriptionByUUID() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = mock(APISubscriptionDAO.class);
AbstractAPIManager apiStore = getAPIStoreImpl(apiSubscriptionDAO);
when(apiSubscriptionDAO.getAPISubscription(UUID)).thenReturn(new Subscription(UUID, null, null, null));
apiStore.getSubscriptionByUUID(UUID);
verify(apiSubscriptionDAO, times(1)).getAPISubscription(UUID);
}
Aggregations