use of org.wso2.carbon.mediation.registry.RegistryServiceHolder in project carbon-apimgt by wso2.
the class GatewayUtilsTestCase method setup.
@Before
public void setup() {
System.setProperty("carbon.home", "jhkjn");
PowerMockito.mockStatic(PrivilegedCarbonContext.class);
PowerMockito.mockStatic(ServiceReferenceHolder.class);
PowerMockito.mockStatic(RegistryServiceHolder.class);
PowerMockito.mockStatic(SubscriptionDataHolder.class);
PrivilegedCarbonContext privilegedCarbonContext = Mockito.mock(PrivilegedCarbonContext.class);
serviceReferenceHolder = Mockito.mock(ServiceReferenceHolder.class);
RegistryServiceHolder registryServiceHolder = Mockito.mock(RegistryServiceHolder.class);
RegistryService registryService = Mockito.mock(RegistryService.class);
userRegistry = Mockito.mock(UserRegistry.class);
resource = Mockito.mock(Resource.class);
PowerMockito.when(PrivilegedCarbonContext.getThreadLocalCarbonContext()).thenReturn(privilegedCarbonContext);
PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(serviceReferenceHolder);
PowerMockito.when(RegistryServiceHolder.getInstance()).thenReturn(registryServiceHolder);
Mockito.when(registryServiceHolder.getRegistryService()).thenReturn(registryService);
Mockito.when(privilegedCarbonContext.getTenantId()).thenReturn(tenantID);
Mockito.when(privilegedCarbonContext.getTenantDomain()).thenReturn("carbon.super");
try {
Mockito.when(registryService.getConfigSystemRegistry(tenantID)).thenReturn(userRegistry);
} catch (RegistryException e) {
fail("Error while mocking registryService.getConfigSystemRegistry");
}
try {
Mockito.when(userRegistry.get(path)).thenReturn(resource);
} catch (RegistryException e) {
fail("Error while mocking userRegistry.get(path)");
}
}
Aggregations