Search in sources :

Example 16 with ConfigurationManager

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);
}
Also used : ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) InputStream(java.io.InputStream) ResourceManagerImpl(org.wso2.carbon.identity.tenant.resource.manager.core.ResourceManagerImpl) ArrayList(java.util.ArrayList) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ResourceManager(org.wso2.carbon.identity.tenant.resource.manager.core.ResourceManager) Resources(org.wso2.carbon.identity.configuration.mgt.core.model.Resources) EventStreamConfiguration(org.wso2.carbon.event.stream.core.EventStreamConfiguration) ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) File(java.io.File)

Aggregations

ConfigurationManager (org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager)8 File (java.io.File)5 IOException (java.io.IOException)5 ConfigurationManagementException (org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException)5 Resource (org.wso2.carbon.identity.configuration.mgt.core.model.Resource)4 TemplateToResource (org.wso2.carbon.identity.template.mgt.function.TemplateToResource)4 ConfigurationManager (org.wso2.carbon.mediation.initializer.configurations.ConfigurationManager)4 InputStream (java.io.InputStream)3 Lock (java.util.concurrent.locks.Lock)3 ReentrantLock (java.util.concurrent.locks.ReentrantLock)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 ConfigurationDAO (org.wso2.carbon.identity.configuration.mgt.core.dao.ConfigurationDAO)3 ConfigurationDAOImpl (org.wso2.carbon.identity.configuration.mgt.core.dao.impl.ConfigurationDAOImpl)3 ConfigurationManagerConfigurationHolder (org.wso2.carbon.identity.configuration.mgt.core.model.ConfigurationManagerConfigurationHolder)3 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)3 ServerContextInformation (org.apache.synapse.ServerContextInformation)2 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)2 BundleContext (org.osgi.framework.BundleContext)2 ServiceRegistration (org.osgi.framework.ServiceRegistration)2 Activate (org.osgi.service.component.annotations.Activate)2