Search in sources :

Example 6 with SubscriptionResponse

use of org.wso2.carbon.apimgt.core.models.SubscriptionResponse in project carbon-apimgt by wso2.

the class APIStoreImplTestCase method testAddSubscriptionForInvalidAPI.

@Test(description = "Add subscription without a valid api", expectedExceptions = APIManagementException.class)
public void testAddSubscriptionForInvalidAPI() 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);
    APIStore apiStore = getApiStoreImpl(apiDAO, applicationDAO, apiSubscriptionDAO, workflowDAO, apiGateway, policyDAO);
    Application application = new Application("TestApp", USER_ID);
    application.setId(UUID);
    Mockito.when(apiDAO.getAPI(API_ID)).thenReturn(null);
    Mockito.when(applicationDAO.getApplication(UUID)).thenReturn(application);
    SubscriptionResponse subscriptionResponse = apiStore.addApiSubscription(API_ID, UUID, TIER);
    String subscriptionId = subscriptionResponse.getSubscriptionUUID();
    Assert.assertNotNull(subscriptionId);
    // subscription should not be added
    Mockito.verify(apiSubscriptionDAO, Mockito.times(0)).addAPISubscription(subscriptionId, API_ID, UUID, TIER, APIMgtConstants.SubscriptionStatus.ON_HOLD);
}
Also used : WorkflowDAO(org.wso2.carbon.apimgt.core.dao.WorkflowDAO) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) SubscriptionResponse(org.wso2.carbon.apimgt.core.models.SubscriptionResponse) APIGateway(org.wso2.carbon.apimgt.core.api.APIGateway) ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) Application(org.wso2.carbon.apimgt.core.models.Application) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) PolicyDAO(org.wso2.carbon.apimgt.core.dao.PolicyDAO) APIStore(org.wso2.carbon.apimgt.core.api.APIStore) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

SubscriptionResponse (org.wso2.carbon.apimgt.core.models.SubscriptionResponse)6 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)5 Application (org.wso2.carbon.apimgt.core.models.Application)5 BeforeTest (org.testng.annotations.BeforeTest)4 Test (org.testng.annotations.Test)4 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)4 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)4 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)4 ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)4 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)4 API (org.wso2.carbon.apimgt.core.models.API)4 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)4 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)3 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)3 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)3 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)2 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)2 Subscription (org.wso2.carbon.apimgt.core.models.Subscription)2 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)2 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)2