use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class ExportApiServiceImplTestCase method exportPoliciesThrottleGetTest.
@Test
public void exportPoliciesThrottleGetTest() throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ExportApiServiceImpl exportApiService = new ExportApiServiceImpl();
LogManager.getRootLogger().setLevel(Level.DEBUG);
Response response = exportApiService.exportPoliciesThrottleGet(null, getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class PoliciesApiServiceImplTestCase method policiesGetTest.
@Test
public void policiesGetTest() throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
PoliciesApiServiceImpl policiesApiService = new PoliciesApiServiceImpl();
PolicyValidationData policyValidationDataOne = new PolicyValidationData(UUID.randomUUID().toString(), "APPLICATION_POLICY", true);
PolicyValidationData policyValidationDataTwo = new PolicyValidationData(UUID.randomUUID().toString(), "APPLICATION_POLICY", true);
PolicyValidationData policyValidationDataThree = new PolicyValidationData(UUID.randomUUID().toString(), "APPLICATION_POLICY", true);
Set<PolicyValidationData> policyValidationDataHashSet = new LinkedHashSet<>();
policyValidationDataHashSet.add(policyValidationDataOne);
policyValidationDataHashSet.add(policyValidationDataTwo);
policyValidationDataHashSet.add(policyValidationDataThree);
Mockito.when(apiMgtAdminService.getAllPolicies()).thenReturn(policyValidationDataHashSet);
Response response = policiesApiService.policiesGet(null, getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertEquals(((PolicyListDTO) response.getEntity()).getList().size(), 3);
}
use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class ResourcesApiServiceImplTestCase method getResponse.
private Response getResponse(String apiContext, String apiVersion) throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ResourcesApiServiceImpl resourcesApiService = new ResourcesApiServiceImpl();
return resourcesApiService.resourcesGet(apiContext, apiVersion, null, getRequest());
}
use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class ResourcesApiServiceImplTestCase method resourcesGetTest.
@Test
public void resourcesGetTest() throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
ResourcesApiServiceImpl resourcesApiService = new ResourcesApiServiceImpl();
UriTemplate uriTemplateOne = SampleTestObjectCreator.createUniqueUriTemplate();
UriTemplate uriTemplateTwo = SampleTestObjectCreator.createUniqueUriTemplate();
UriTemplate uriTemplateThree = SampleTestObjectCreator.createUniqueUriTemplate();
List<UriTemplate> uriTemplateList = new ArrayList<>();
uriTemplateList.add(uriTemplateOne);
uriTemplateList.add(uriTemplateTwo);
uriTemplateList.add(uriTemplateThree);
Mockito.when(apiMgtAdminService.getAllResourcesForApi(API_CONTEXT, API_VERSION)).thenReturn(uriTemplateList);
Response response = resourcesApiService.resourcesGet(API_CONTEXT, API_VERSION, null, getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertEquals(((ResourcesListDTO) response.getEntity()).getList().size(), 3);
}
use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class SubscriptionsApiServiceImplTestCase method subscriptionsGetTest.
@Test
public void subscriptionsGetTest() throws Exception {
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
APIManagerFactory instance = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
PowerMockito.when(APIManagerFactory.getInstance()).thenReturn(instance);
Mockito.when(instance.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
SubscriptionsApiServiceImpl subscriptionsApiService = new SubscriptionsApiServiceImpl();
Mockito.when(apiMgtAdminService.getAPISubscriptionsOfApi(API_CONTEXT, API_VERSION)).thenReturn(createSubscriptionValidationDataList());
Response response = subscriptionsApiService.subscriptionsGet(API_CONTEXT, API_VERSION, LIMIT, null, getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertEquals(((SubscriptionListDTO) response.getEntity()).getList().size(), 2);
}
Aggregations