use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class ConfigurationsAPITestCase method setup.
@BeforeTest
public void setup() throws Exception {
WorkflowExtensionsConfigBuilder.build(new ConfigProvider() {
@Override
public <T> T getConfigurationObject(Class<T> configClass) throws ConfigurationException {
T workflowConfig = (T) new WorkflowConfig();
return workflowConfig;
}
@Override
public Object getConfigurationObject(String s) throws ConfigurationException {
return null;
}
public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException {
return null;
}
});
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
ServiceReferenceHolder.getInstance().setConfigProvider(configProvider);
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testGetEnvironmentConfigurations.
@Test
public void testGetEnvironmentConfigurations() {
ServiceReferenceHolder instance = ServiceReferenceHolder.getInstance();
// //Happy Path
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
instance.setConfigProvider(configProvider);
APIMUIConfigurations apimUIConfigurations = instance.getApimUIConfigurations();
Assert.assertNotNull(apimUIConfigurations);
// //ConfigProvider is null
instance.setConfigProvider(null);
apimUIConfigurations = instance.getApimUIConfigurations();
Assert.assertNotNull(apimUIConfigurations);
// //CarbonConfigurationException when reading configs
configProvider = new ConfigProvider() {
@Override
public <T> T getConfigurationObject(Class<T> configClass) throws ConfigurationException {
throw new ConfigurationException("Error while creating configuration instance");
}
@Override
public Object getConfigurationObject(String namespace) throws ConfigurationException {
throw new ConfigurationException("Error while creating configuration instance");
}
public <T> T getConfigurationObject(String s, Class<T> aClass) throws ConfigurationException {
return null;
}
};
instance.setConfigProvider(configProvider);
apimUIConfigurations = instance.getApimUIConfigurations();
Assert.assertNotNull(apimUIConfigurations);
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class ServiceReferenceHolder method getApimUIConfigurations.
public APIMUIConfigurations getApimUIConfigurations() {
try {
if (configProvider != null) {
apimUIConfigurations = configProvider.getConfigurationObject(APIMUIConfigurations.class);
} else {
log.error("Configuration provider is null");
}
} catch (ConfigurationException e) {
log.error("Error getting config : org.wso2.carbon.apimgt.rest.api.configurations.models." + "EnvironmentConfigurations", e);
}
if (apimUIConfigurations == null) {
apimUIConfigurations = new APIMUIConfigurations();
log.info("Setting default configurations...");
}
return apimUIConfigurations;
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testGetAvailableFeaturesForException.
@Test
public void testGetAvailableFeaturesForException() throws ConfigurationException {
ServiceReferenceHolder instance = ServiceReferenceHolder.getInstance();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
instance.setConfigProvider(configProvider);
Mockito.when(configProvider.getConfigurationObject(Mockito.anyString())).thenThrow(ConfigurationException.class);
Map<String, Feature> featureList = instance.getAvailableFeatures();
Assert.assertNotNull(featureList);
}
use of org.wso2.carbon.config.ConfigurationException in project carbon-apimgt by wso2.
the class ServiceReferenceHolderTestCase method testGetAvailableFeatures.
@Test
public void testGetAvailableFeatures() throws ConfigurationException {
// //Happy Path
ServiceReferenceHolder instance = ServiceReferenceHolder.getInstance();
ConfigProvider configProvider = Mockito.mock(ConfigProvider.class);
instance.setConfigProvider(configProvider);
Map configs = new HashMap<>();
configs.put(ConfigurationAPIConstants.ENABLED, true);
Mockito.when(configProvider.getConfigurationObject(Mockito.anyString())).thenReturn(configs);
Map<String, Feature> featureList = instance.getAvailableFeatures();
Assert.assertNotNull(featureList);
}
Aggregations