use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testGetApplicationByUUIDException.
@Test(description = "Exception when retrieving an application by uuid", expectedExceptions = APIManagementException.class)
public void testGetApplicationByUUIDException() throws APIManagementException {
ApplicationDAO applicationDAO = Mockito.mock(ApplicationDAO.class);
APIStore apiStore = getApiStoreImpl(applicationDAO);
Mockito.when(applicationDAO.getApplication(UUID)).thenThrow(new APIMgtDAOException("Error occurred while retrieving application - " + UUID, new SQLException()));
apiStore.getApplicationByUuid(UUID);
}
use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method searchAPIsByStoreLabels.
@Test(description = "Search APIs with labels")
public void searchAPIsByStoreLabels() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIStore apiStore = getApiStoreImpl(apiDAO);
List<API> apimResultsFromDAO = new ArrayList<>();
List<String> labelList = new ArrayList<>();
labelList.add("Default");
Mockito.when(apiDAO.searchAPIsByStoreLabel(new HashSet<>(), "admin", "pizza", 1, 2, labelList)).thenReturn(apimResultsFromDAO);
List<API> apis = apiStore.searchAPIsByStoreLabels("pizza", 1, 2, labelList);
Assert.assertNotNull(apis);
Mockito.verify(apiDAO, Mockito.atLeastOnce()).searchAPIsByStoreLabel(APIUtils.getAllRolesOfUser("admin"), "admin", "pizza", 1, 2, labelList);
}
use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testGetAllCommentsForApiException.
@Test(description = "Exception in dao when retrieving all comments", expectedExceptions = APIManagementException.class)
public void testGetAllCommentsForApiException() throws APIManagementException {
ApiDAO apiDAO = Mockito.mock(ApiDAO.class);
APIStore apiStore = getApiStoreImpl(apiDAO);
API api = SampleTestObjectCreator.createDefaultAPI().build();
Mockito.when(apiDAO.getAPI(api.getId())).thenReturn(api);
Mockito.doThrow(new APIMgtDAOException("Error occurred while retrieving all comments for api " + api.getId(), new SQLException())).when(apiDAO).getCommentsForApi(api.getId());
apiStore.getCommentsForApi(api.getId());
}
use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method getLabelsByType.
@Test(description = "get labels by STORE type")
public void getLabelsByType() throws Exception {
LabelDAO labelDao = Mockito.mock(LabelDAO.class);
APIStore apiStore = getApiStoreImpl(labelDao);
List<Label> labels = new ArrayList<>();
Label label = new Label.Builder().id("123").name("Default").type("STORE").accessUrls(new ArrayList<>()).build();
labels.add(label);
Mockito.when(labelDao.getLabelsByType("STORE")).thenReturn(labels);
List<Label> returnedLabels = apiStore.getLabelsByType("STORE");
Assert.assertNotNull(returnedLabels);
Mockito.verify(labelDao, Mockito.atLeastOnce()).getLabelsByType("STORE");
}
use of org.wso2.carbon.apimgt.api.model.APIStore in project carbon-apimgt by wso2.
the class APIStoreImplTestCase method testGetPolicy.
@Test(description = "Get policy given policy name and policy level")
public void testGetPolicy() throws APIManagementException {
PolicyDAO policyDAO = Mockito.mock(PolicyDAO.class);
APIStore apiStore = getApiStoreImpl(policyDAO);
apiStore.getPolicy(APIMgtAdminService.PolicyLevel.application, POLICY_NAME);
Mockito.verify(policyDAO, Mockito.times(1)).getPolicyByLevelAndName(APIMgtAdminService.PolicyLevel.application, POLICY_NAME);
}
Aggregations