use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class APIConsumerAdminTestCase method testResumeWorkflow.
@Test
public void testResumeWorkflow() throws Exception {
APIManagerFactory apiManagerFactory = Mockito.mock(APIManagerFactory.class);
PowerMockito.mockStatic(APIManagerFactory.class);
Mockito.when(APIManagerFactory.getInstance()).thenReturn(apiManagerFactory);
APIConsumer consumer = Mockito.mock(APIConsumer.class);
Mockito.when(apiManagerFactory.getAPIConsumer("")).thenReturn(consumer);
APIConsumerAdmin apiConsumerAdmin = new APIConsumerAdmin();
apiConsumerAdmin.resumeWorkflow(null, "");
Mockito.verify(consumer, Mockito.times(1)).resumeWorkflow(null);
}
use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class RestApiCommonUtilTest method testGetConsumer.
@Test
public void testGetConsumer() throws APIManagementException {
String userName = "TEST_USER";
APIConsumer apiConsumer = Mockito.mock(APIConsumer.class);
PowerMockito.mockStatic(APIManagerFactory.class);
APIManagerFactory apiManagerFactory = Mockito.mock(APIManagerFactory.class);
when(APIManagerFactory.getInstance()).thenReturn(apiManagerFactory);
when(apiManagerFactory.getAPIConsumer(userName)).thenReturn(apiConsumer);
Assert.assertEquals(apiConsumer, RestApiCommonUtil.getConsumer(userName));
}
use of org.wso2.carbon.apimgt.core.impl.APIManagerFactory in project carbon-apimgt by wso2.
the class RestApiCommonUtilTest method testGetLoggedInUserProvider.
@Test
public void testGetLoggedInUserProvider() throws Exception {
System.setProperty(CARBON_HOME, "");
String providerName = "admin";
PowerMockito.mockStatic(APIManagerFactory.class);
APIManagerFactory apiManagerFactory = Mockito.mock(APIManagerFactory.class);
when(APIManagerFactory.getInstance()).thenReturn(apiManagerFactory);
APIProvider testApiProvider = Mockito.mock(APIProvider.class);
when(apiManagerFactory.getAPIProvider(providerName)).thenReturn(testApiProvider);
PowerMockito.mockStatic(RestApiCommonUtil.class);
when(RestApiCommonUtil.getLoggedInUsername()).thenReturn(providerName);
when(RestApiCommonUtil.getLoggedInUserProvider()).thenCallRealMethod();
APIProvider loggedInUserProvider = RestApiCommonUtil.getLoggedInUserProvider();
Assert.assertEquals(testApiProvider, loggedInUserProvider);
}
Aggregations