use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testDeleteLabelException.
@Test(description = "Exception when deleting a label", expectedExceptions = APIManagementException.class)
public void testDeleteLabelException() throws APIManagementException {
LabelDAO labelDAO = Mockito.mock(LabelDAO.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(labelDAO);
Label label = SampleTestObjectCreator.createLabel("Public", SampleTestObjectCreator.LABEL_TYPE_STORE).build();
String labelId = label.getId();
Mockito.doThrow(new APIMgtDAOException("Error occurred while deleting label [labelId] " + labelId)).when(labelDAO).deleteLabel(labelId);
adminService.deleteLabel(labelId);
Mockito.verify(labelDAO, Mockito.times(1)).deleteLabel(labelId);
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class APIMgtAdminServiceImplTestCase method testGetAPISubscriptions.
@Test(description = "Get api subscriptions")
public void testGetAPISubscriptions() throws APIManagementException {
APISubscriptionDAO apiSubscriptionDAO = Mockito.mock(APISubscriptionDAO.class);
APIMgtAdminServiceImpl adminService = getAPIMgtAdminServiceImpl(apiSubscriptionDAO);
Mockito.when(apiSubscriptionDAO.getAPISubscriptionsOfAPIForValidation(LIMIT)).thenReturn(new ArrayList<>());
adminService.getAPISubscriptions(LIMIT);
Mockito.verify(apiSubscriptionDAO, Mockito.times(1)).getAPISubscriptionsOfAPIForValidation(LIMIT);
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisGetApisNullStatusTestCase.
@Test
public void apisGetApisNullStatusTestCase() throws Exception {
String labels = "ZONE_ONE,ZONE_TWO";
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Response response = apisApiService.apisGet(labels, null, getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisGetTestCase.
@Test
public void apisGetTestCase() throws Exception {
String labels = "ZONE_ONE,ZONE_TWO";
String[] gatewayLabels = labels.split(",");
List<String> labelList = new ArrayList<String>(Arrays.asList(gatewayLabels));
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
List<API> apiList = new ArrayList<>();
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
Mockito.when(apiMgtAdminService.getAPIsByStatus(labelList, "Published")).thenReturn(apiList);
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Response response = apisApiService.apisGet(labels, "Published", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Integer count = ((APIListDTO) response.getEntity()).getCount();
Assert.assertEquals(count.intValue(), 3);
}
use of org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisGetApisNullLabelsTestCase.
@Test
public void apisGetApisNullLabelsTestCase() throws Exception {
String labels = null;
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Response response = apisApiService.apisGet(labels, "Published", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
Aggregations