use of org.wso2.carbon.utils.ConfigurationContextService in project carbon-apimgt by wso2.
the class TestUtils method getServiceReferenceHolder.
public static ServiceReferenceHolder getServiceReferenceHolder() throws XMLStreamException {
PowerMockito.mockStatic(ServiceReferenceHolder.class);
ServiceReferenceHolder sh = PowerMockito.mock(ServiceReferenceHolder.class);
PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(sh);
ConfigurationContextService configurationContextService = initConfigurationContextService(false);
PowerMockito.when(ServiceReferenceHolder.getContextService()).thenReturn(configurationContextService);
return sh;
}
use of org.wso2.carbon.utils.ConfigurationContextService in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testServiceReferenceHolder.
@Test
public void testServiceReferenceHolder() {
ServiceReferenceHolder serviceReferenceHolder = ServiceReferenceHolder.getInstance();
Assert.assertTrue(serviceReferenceHolder instanceof ServiceReferenceHolder);
serviceReferenceHolder.getThrottleDataHolder();
ThrottleDataHolder throttleDataHolder = Mockito.mock(ThrottleDataHolder.class);
serviceReferenceHolder.setThrottleDataHolder(throttleDataHolder);
ConfigurationContextService cfgCtxService = Mockito.mock(ConfigurationContextService.class);
serviceReferenceHolder.setConfigurationContextService(cfgCtxService);
cfgCtxService = serviceReferenceHolder.getConfigurationContextService();
Assert.assertNotNull(cfgCtxService);
APIManagerConfigurationService apiManagerConfigurationService = Mockito.mock(APIManagerConfigurationService.class);
serviceReferenceHolder.setAPIManagerConfigurationService(apiManagerConfigurationService);
apiManagerConfigurationService = serviceReferenceHolder.getApiManagerConfigurationService();
Assert.assertNotNull(apiManagerConfigurationService);
Assert.assertNull(serviceReferenceHolder.getAPIManagerConfiguration());
Assert.assertNull(serviceReferenceHolder.getServerConfigurationContext());
ThrottleProperties throttleProperties = Mockito.mock(ThrottleProperties.class);
serviceReferenceHolder.setThrottleProperties(throttleProperties);
Assert.assertNotNull(serviceReferenceHolder.getThrottleProperties());
}
use of org.wso2.carbon.utils.ConfigurationContextService in project carbon-apimgt by wso2.
the class ApplicationRegistrationWSWorkflowExecutorTest method init.
@Before
public void init() throws Exception {
ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
configurationContext = Mockito.mock(ConfigurationContext.class);
PowerMockito.when(serviceReferenceHolder.getContextService()).thenReturn(configurationContextService);
PowerMockito.when(configurationContextService.getClientConfigContext()).thenReturn(configurationContext);
serviceClient = Mockito.mock(ServiceClient.class);
PowerMockito.whenNew(ServiceClient.class).withAnyArguments().thenReturn(serviceClient);
applicationRegistrationWSWorkflowExecutor = new ApplicationRegistrationWSWorkflowExecutor();
apiMgtDAO = TestUtils.getApiMgtDAO();
application = new Application("test", new Subscriber("testUser"));
application.setCallbackUrl(callBaclURL);
application.setTier("Unlimited");
PowerMockito.mockStatic(KeyManagerHolder.class);
keyManager = Mockito.mock(KeyManager.class);
KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
Mockito.when(keyManager.getKeyManagerConfiguration()).thenReturn(keyManagerConfiguration);
PowerMockito.when(KeyManagerHolder.getKeyManagerInstance("carbon.super", "default")).thenReturn(keyManager);
OAuthApplicationInfo oAuthApplicationInfo = new OAuthApplicationInfo();
PowerMockito.when(keyManager.createApplication((OAuthAppRequest) Mockito.anyObject())).thenReturn(oAuthApplicationInfo);
OAuthAppRequest oAuthAppRequest = new OAuthAppRequest();
oAuthAppRequest.setOAuthApplicationInfo(oAuthApplicationInfo);
workflowDTO = new ApplicationRegistrationWorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setApplication(application);
workflowDTO.setCallbackUrl(callBaclURL);
workflowDTO.setTenantDomain("carbon.super");
workflowDTO.setUserName("testUser");
workflowDTO.setExternalWorkflowReference("testUser");
workflowDTO.setKeyType("PRODUCTION");
workflowDTO.setAppInfoDTO(oAuthAppRequest);
KeyManagerConfigurationDTO kmConfigDTO = new KeyManagerConfigurationDTO();
kmConfigDTO.setOrganization("carbon.super");
kmConfigDTO.setName("default");
PowerMockito.when(apiMgtDAO.getKeyManagerConfigurationByUUID("default")).thenReturn(kmConfigDTO);
}
use of org.wso2.carbon.utils.ConfigurationContextService in project carbon-apimgt by wso2.
the class UserSignUpWSWorkflowExecutorTest method init.
@Before
public void init() throws Exception {
ServiceReferenceHolder serviceReferenceHolder = TestUtils.getServiceReferenceHolder();
ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class);
ConfigurationContext configurationContext = Mockito.mock(ConfigurationContext.class);
RealmService realmService = Mockito.mock(RealmService.class);
UserRealm userRealm = Mockito.mock(UserRealm.class);
userStoreManager = Mockito.mock(UserStoreManager.class);
TenantManager tenantManager = Mockito.mock(TenantManager.class);
apiManagerConfiguration = Mockito.mock(APIManagerConfiguration.class);
serviceClient = Mockito.mock(ServiceClient.class);
APIManagerConfigurationService apiManagerConfigurationService = new APIManagerConfigurationServiceImpl(apiManagerConfiguration);
PowerMockito.mockStatic(SelfSignUpUtil.class);
PowerMockito.mockStatic(CarbonUtils.class);
PowerMockito.mockStatic(APIUtil.class);
PowerMockito.when(APIUtil.isAnalyticsEnabled()).thenReturn(true);
PowerMockito.doNothing().when(CarbonUtils.class, "setBasicAccessSecurityHeaders", Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any());
PowerMockito.when(serviceReferenceHolder.getContextService()).thenReturn(configurationContextService);
PowerMockito.when(configurationContextService.getClientConfigContext()).thenReturn(configurationContext);
PowerMockito.when(serviceReferenceHolder.getAPIManagerConfigurationService()).thenReturn(apiManagerConfigurationService);
PowerMockito.whenNew(ServiceClient.class).withAnyArguments().thenReturn(serviceClient);
Mockito.when(serviceReferenceHolder.getRealmService()).thenReturn(realmService);
Mockito.when(realmService.getTenantManager()).thenReturn(tenantManager);
Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
Mockito.when(realmService.getTenantUserRealm(tenantID)).thenReturn(userRealm);
Mockito.when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
apiMgtDAO = TestUtils.getApiMgtDAO();
userSignUpWSWorkflowExecutor = new UserSignUpWSWorkflowExecutor();
workflowDTO = new WorkflowDTO();
workflowDTO.setCallbackUrl(callBackURL);
workflowDTO.setTenantDomain(tenantDomain);
workflowDTO.setExternalWorkflowReference(externalWFReference);
workflowDTO.setWorkflowReference(testUsername + "@carbon.super");
}
Aggregations