Search in sources :

Example 11 with ConfigurationException

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);
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) BeforeTest(org.testng.annotations.BeforeTest)

Example 12 with ConfigurationException

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);
}
Also used : ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) APIMUIConfigurations(org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations) Test(org.testng.annotations.Test)

Example 13 with ConfigurationException

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;
}
Also used : ConfigurationException(org.wso2.carbon.config.ConfigurationException) APIMUIConfigurations(org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations)

Example 14 with ConfigurationException

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);
}
Also used : ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) Feature(org.wso2.carbon.apimgt.rest.api.configurations.models.Feature) Test(org.testng.annotations.Test)

Example 15 with ConfigurationException

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);
}
Also used : ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Feature(org.wso2.carbon.apimgt.rest.api.configurations.models.Feature) Test(org.testng.annotations.Test)

Aggregations

ConfigProvider (org.wso2.carbon.config.provider.ConfigProvider)12 ConfigurationException (org.wso2.carbon.config.ConfigurationException)9 Test (org.junit.Test)5 HashMap (java.util.HashMap)3 Test (org.testng.annotations.Test)3 WorkflowConfig (org.wso2.carbon.apimgt.core.models.WorkflowConfig)3 Feature (org.wso2.carbon.apimgt.rest.api.configurations.models.Feature)3 Path (java.nio.file.Path)2 Map (java.util.Map)2 BeforeTest (org.testng.annotations.BeforeTest)2 BrokerConfigProvider (org.wso2.broker.common.BrokerConfigProvider)2 ContainerBasedGatewayConfiguration (org.wso2.carbon.apimgt.core.configuration.models.ContainerBasedGatewayConfiguration)2 APIMAppConfigurations (org.wso2.carbon.apimgt.rest.api.authenticator.configuration.models.APIMAppConfigurations)2 APIMUIConfigurations (org.wso2.carbon.apimgt.rest.api.configurations.models.APIMUIConfigurations)2 File (java.io.File)1 Iterator (java.util.Iterator)1 List (java.util.List)1 QName (javax.xml.namespace.QName)1 OXPath20ExpressionBPEL20 (org.apache.ode.bpel.elang.xpath20.o.OXPath20ExpressionBPEL20)1 ConfigurationException (org.apache.ode.bpel.explang.ConfigurationException)1