Search in sources :

Example 31 with APIManagerFactory

use of org.wso2.carbon.apimgt.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);
}
Also used : APIManagerFactory(org.wso2.carbon.apimgt.impl.APIManagerFactory) APIConsumer(org.wso2.carbon.apimgt.api.APIConsumer) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 32 with APIManagerFactory

use of org.wso2.carbon.apimgt.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));
}
Also used : APIManagerFactory(org.wso2.carbon.apimgt.impl.APIManagerFactory) APIConsumer(org.wso2.carbon.apimgt.api.APIConsumer) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 33 with APIManagerFactory

use of org.wso2.carbon.apimgt.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);
}
Also used : APIManagerFactory(org.wso2.carbon.apimgt.impl.APIManagerFactory) APIProvider(org.wso2.carbon.apimgt.api.APIProvider) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Test (org.junit.Test)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)31 APIManagerFactory (org.wso2.carbon.apimgt.core.impl.APIManagerFactory)27 Response (javax.ws.rs.core.Response)23 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)17 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)6 ArrayList (java.util.ArrayList)5 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)5 API (org.wso2.carbon.apimgt.core.models.API)5 Request (org.wso2.msf4j.Request)4 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)3 ThreatProtectionPolicy (org.wso2.carbon.apimgt.core.models.policy.ThreatProtectionPolicy)3 APIManagerFactory (org.wso2.carbon.apimgt.impl.APIManagerFactory)3 APIConsumer (org.wso2.carbon.apimgt.api.APIConsumer)2 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)2 ThreatProtectionPolicyDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThreatProtectionPolicyDTO)2 File (java.io.File)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Properties (java.util.Properties)1