Search in sources :

Example 96 with APIStore

use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testSearchAPIByUUID.

@Test(description = "Search API by UUID")
public void testSearchAPIByUUID() throws APIManagementException {
    ApiDAO apiDAO = mock(ApiDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiDAO);
    API apiFromDAO = new API.APIBuilder(PROVIDER_NAME, API_NAME, API_VERSION).build();
    when(apiDAO.getAPI(UUID)).thenReturn(apiFromDAO);
    API api = apiStore.getAPIbyUUID(UUID);
    Assert.assertEquals(api.getName(), API_NAME);
    verify(apiDAO, atLeastOnce()).getAPI(UUID);
}
Also used : API(org.wso2.carbon.apimgt.core.models.API) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 97 with APIStore

use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testGetDocumentationSummaryException.

@Test(description = "Exception when retrieving documentation summary given the id", expectedExceptions = APIManagementException.class)
public void testGetDocumentationSummaryException() throws APIManagementException {
    ApiDAO apiDAO = mock(ApiDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiDAO);
    when(apiDAO.getDocumentInfo(UUID)).thenThrow(new APIMgtDAOException("Error occurred while retrieving documents", new SQLException()));
    apiStore.getDocumentationSummary(UUID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) SQLException(java.sql.SQLException) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 98 with APIStore

use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testGetLastUpdatedTimeOfApplicationException.

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

Example 99 with APIStore

use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.

the class AbstractAPIManagerTestCase method testSearchAPIByUUIDException.

@Test(description = "Exception when getting API by UUID", expectedExceptions = APIManagementException.class)
public void testSearchAPIByUUIDException() throws APIManagementException {
    ApiDAO apiDAO = mock(ApiDAO.class);
    AbstractAPIManager apiStore = getAPIStoreImpl(apiDAO);
    when(apiDAO.getAPI(UUID)).thenThrow(new APIMgtDAOException("Error occurred while retrieving API with id " + UUID, new SQLException()));
    apiStore.getAPIbyUUID(UUID);
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) SQLException(java.sql.SQLException) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO) Test(org.testng.annotations.Test)

Example 100 with APIStore

use of org.wso2.carbon.apimgt.api.model.APIStore 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);
}
Also used : APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) Subscription(org.wso2.carbon.apimgt.core.models.Subscription) Test(org.testng.annotations.Test)

Aggregations

APIStore (org.wso2.carbon.apimgt.core.api.APIStore)226 Test (org.testng.annotations.Test)109 Test (org.junit.Test)98 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)96 BeforeTest (org.testng.annotations.BeforeTest)93 Response (javax.ws.rs.core.Response)90 Request (org.wso2.msf4j.Request)87 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)72 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)56 API (org.wso2.carbon.apimgt.core.models.API)51 HashMap (java.util.HashMap)49 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)49 ArrayList (java.util.ArrayList)47 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)47 Application (org.wso2.carbon.apimgt.core.models.Application)46 ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)38 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)32 SQLException (java.sql.SQLException)31 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)31 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)29