Search in sources :

Example 56 with APISubscriptionDAO

use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.

the class APIStoreImplTestCase method testDeleteSubscriptionException.

@Test(description = "Exception when deleting subscription", expectedExceptions = APIManagementException.class)
public void testDeleteSubscriptionException() throws APIManagementException {
    ApplicationDAO applicationDAO = Mockito.mock(ApplicationDAO.class);
    APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
    APIStore apiStore = getApiStoreImpl(applicationDAO, apiSubscriptionDAO);
    Mockito.doThrow(new APIMgtDAOException("Error occurred while deleting api subscription " + UUID, new SQLException())).when(apiSubscriptionDAO).deleteAPISubscription(UUID);
    apiStore.deleteAPISubscription(UUID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) SQLException(java.sql.SQLException) ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) APIStore(org.wso2.carbon.apimgt.core.api.APIStore) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 57 with APISubscriptionDAO

use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testGetLastUpdatedTimeOfSubscriptionException.

@Test(description = "Exception when getting last updated time of Subscription", expectedExceptions = APIManagementException.class)
public void testGetLastUpdatedTimeOfSubscriptionException() throws APIManagementException {
    APISubscriptionDAO apiSubscriptionDAO = mock(APISubscriptionDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiSubscriptionDAO);
    when(apiSubscriptionDAO.getLastUpdatedTimeOfSubscription(UUID)).thenThrow(new APIMgtDAOException("Error occurred while retrieving the last updated time of the subscription " + UUID, new SQLException()));
    apiStore.getLastUpdatedTimeOfSubscription(UUID);
    verify(apiSubscriptionDAO, times(0)).getLastUpdatedTimeOfSubscription(UUID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test)

Example 58 with APISubscriptionDAO

use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testGetSubscriptionByUUIDException.

@Test(description = "Exception when getting subscription by UUID", expectedExceptions = APIManagementException.class)
public void testGetSubscriptionByUUIDException() throws APIManagementException {
    APISubscriptionDAO apiSubscriptionDAO = mock(APISubscriptionDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiSubscriptionDAO);
    when(apiSubscriptionDAO.getAPISubscription(UUID)).thenThrow(new APIMgtDAOException("Couldn't retrieve subscription for id " + UUID, new SQLException()));
    apiStore.getSubscriptionByUUID(UUID);
    verify(apiSubscriptionDAO, times(0)).getAPISubscription(UUID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test)

Example 59 with APISubscriptionDAO

use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testGetLastUpdatedTimeOfSubscription.

@Test(description = "Getting last updated time of Subscription")
public void testGetLastUpdatedTimeOfSubscription() throws APIManagementException {
    APISubscriptionDAO apiSubscriptionDAO = mock(APISubscriptionDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiSubscriptionDAO);
    when(apiSubscriptionDAO.getLastUpdatedTimeOfSubscription(UUID)).thenReturn(LAST_UPDATED_TIME);
    apiStore.getLastUpdatedTimeOfSubscription(UUID);
    verify(apiSubscriptionDAO, times(1)).getLastUpdatedTimeOfSubscription(UUID);
}
Also used : APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) Test(org.testng.annotations.Test)

Example 60 with APISubscriptionDAO

use of org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testGetSubscriptionsByAPIException.

@Test(description = "Exception when getting subscriptions by API", expectedExceptions = APIManagementException.class)
public void testGetSubscriptionsByAPIException() throws APIManagementException {
    APISubscriptionDAO apiSubscriptionDAO = mock(APISubscriptionDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiSubscriptionDAO);
    when(apiSubscriptionDAO.getAPISubscriptionsByAPI(UUID)).thenThrow(new APIMgtDAOException("Couldn't find subscriptions for apiId " + UUID, new SQLException()));
    apiStore.getSubscriptionsByAPI(UUID);
    verify(apiSubscriptionDAO, times(0)).getAPISubscriptionsByAPI(UUID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test)

Aggregations

APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)59 Test (org.testng.annotations.Test)54 API (org.wso2.carbon.apimgt.core.models.API)30 Application (org.wso2.carbon.apimgt.core.models.Application)24 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)22 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)18 ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)18 Subscription (org.wso2.carbon.apimgt.core.models.Subscription)18 BeforeTest (org.testng.annotations.BeforeTest)14 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)14 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)14 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)12 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)11 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)10 SQLException (java.sql.SQLException)8 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)8 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)8 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)6 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)5 SubscriptionValidationData (org.wso2.carbon.apimgt.core.models.SubscriptionValidationData)5