use of org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager in project identity-governance by wso2-extensions.
the class TenantAwareAxis2ConfigurationContextObserverTest method prepareConfigs.
private void prepareConfigs() throws Exception {
mockCarbonContext();
mockedTenantResourceManagerDataHolder.when(TenantResourceManagerDataHolder::getInstance).thenReturn(tenantResourceManagerDataHolder);
mockedIdentityTenantUtil.when(() -> IdentityTenantUtil.getTenantDomain(anyInt())).thenReturn(TENANT_DOMAIN);
ResourceFile resourceFile = new ResourceFile();
resourceFile.setName(EMAIL_PUBLISHER);
List<ResourceFile> resourceFiles = new ArrayList<>();
resourceFiles.add(resourceFile);
ResourceManager resourceManager = new ResourceManagerImpl();
Mockito.when(tenantResourceManagerDataHolder.getResourceManager()).thenReturn(resourceManager);
Mockito.when(tenantResourceManagerDataHolder.getCarbonEventPublisherService()).thenReturn(carbonEventPublisherService);
Mockito.when(tenantResourceManagerDataHolder.getCarbonEventStreamService()).thenReturn(eventStreamService);
Mockito.when(tenantResourceManagerDataHolder.getConfigurationManager()).thenReturn(configurationManager);
Mockito.when(tenantResourceManagerDataHolder.getCarbonEventPublisherService()).thenReturn(carbonEventPublisherService);
File sampleResourceFile = new File(getSamplesPath());
InputStream fileStream = FileUtils.openInputStream(sampleResourceFile);
Mockito.when(configurationManager.getFileById(anyString(), anyString(), anyString())).thenReturn(fileStream);
Resources resources = new Resources();
Resource resource = new Resource();
resource.setFiles(resourceFiles);
List<Resource> resourceList = new ArrayList<Resource>();
resourceList.add(resource);
resources.setResources(resourceList);
Mockito.when(configurationManager.getResourcesByType(anyString())).thenReturn(resources);
Mockito.when(eventStreamService.getStreamDefinition(anyString(), anyString())).thenReturn(streamDefinition);
List<EventStreamConfiguration> eventStreamConfigurationsList = new ArrayList<>();
EventStreamConfiguration eventStreamConfiguration = new EventStreamConfiguration();
eventStreamConfiguration.setFileName(EMAIL_PUBLISHER);
mockedTenantResourceManagerDataHolder.when(() -> TenantResourceManagerDataHolder.getInstance().getCarbonEventStreamService().getAllEventStreamConfigurations()).thenReturn(eventStreamConfigurationsList);
}
Aggregations