use of org.wso2.carbon.apimgt.rest.api.store.v1.SubscriptionsApiService in project carbon-apimgt by wso2.
the class SubscriptionsApiServiceImplTestCase method testSubscriptionsGet.
@Test
public void testSubscriptionsGet() throws Exception {
printTestMethodName();
SubscriptionsApiServiceImpl subscriptionsApiService = new SubscriptionsApiServiceImpl();
APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
List<Subscription> subscriptions = new ArrayList<>();
String sub1 = UUID.randomUUID().toString();
String sub2 = UUID.randomUUID().toString();
subscriptions.add(SampleTestObjectCreator.createSubscription(sub1));
subscriptions.add(SampleTestObjectCreator.createSubscription(sub2));
PowerMockito.mockStatic(RestAPIPublisherUtil.class);
PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
String apiId = UUID.randomUUID().toString();
Mockito.doReturn(subscriptions).doThrow(new IllegalArgumentException()).when(apiPublisher).getSubscriptionsByAPI(apiId);
Response response = subscriptionsApiService.subscriptionsGet(apiId, 10, 0, null, getRequest());
assertEquals(response.getStatus(), 200);
assertTrue(response.getEntity().toString().contains(sub1));
assertTrue(response.getEntity().toString().contains(sub2));
}
Aggregations