Search in sources :

Example 1 with WorkflowConfig

use of org.wso2.carbon.apimgt.core.models.WorkflowConfig in project carbon-apimgt by wso2.

the class WorkflowConfigHolder method load.

public void load() throws WorkflowException {
    workflowExecutorMap = new ConcurrentHashMap<>();
    try {
        WorkflowConfig config = WorkflowExtensionsConfigBuilder.getWorkflowConfig();
        // Load application creation workflow configurations
        loadWorkflowConfigurations(config.getApplicationCreation(), WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
        // Load application deletion workflow configurations
        loadWorkflowConfigurations(config.getApplicationDeletion(), WorkflowConstants.WF_TYPE_AM_APPLICATION_DELETION);
        // Load subscription creation workflow configurations
        loadWorkflowConfigurations(config.getSubscriptionCreation(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
        // Load subscription deletion workflow configurations
        loadWorkflowConfigurations(config.getSubscriptionDeletion(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_DELETION);
        // Load api state change workflow configurations
        loadWorkflowConfigurations(config.getApiStateChange(), WorkflowConstants.WF_TYPE_AM_API_STATE);
        // Load application update workflow configurations
        loadWorkflowConfigurations(config.getApplicationUpdate(), WorkflowConstants.WF_TYPE_AM_APPLICATION_UPDATE);
    } catch (ClassNotFoundException e) {
        handleException("Unable to find class", e);
    } catch (InstantiationException e) {
        handleException("Unable to instantiate class", e);
    } catch (IllegalAccessException e) {
        handleException("Illegal attempt to invoke class methods", e);
    } catch (WorkflowException e) {
        handleException("Unable to load workflow executor class", e);
    }
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) WorkflowException(org.wso2.carbon.apimgt.core.exception.WorkflowException)

Example 2 with WorkflowConfig

use of org.wso2.carbon.apimgt.core.models.WorkflowConfig in project carbon-apimgt by wso2.

the class WorkflowExtensionsConfigBuilderTestCase method testWorkflowConfigWithoutConfigFile.

@Test(description = "Test situation where workflow config file loading during a missing config file")
public void testWorkflowConfigWithoutConfigFile() {
    WorkflowConfig config = WorkflowExtensionsConfigBuilder.getWorkflowConfig();
    Assert.assertNotNull(config.getApplicationCreation(), "Default application creation workflow not set");
    Assert.assertNotNull(config.getSubscriptionCreation(), "Default subscription creation workflow not set");
    Assert.assertNotNull(config.getApplicationDeletion(), "Default application deletion workflow not set");
    Assert.assertNotNull(config.getSubscriptionDeletion(), "Default subscription deletion workflow not set");
    WorkflowExtensionsConfigBuilder obj = new WorkflowExtensionsConfigBuilder();
    Assert.assertNotNull(obj);
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) Test(org.testng.annotations.Test)

Example 3 with WorkflowConfig

use of org.wso2.carbon.apimgt.core.models.WorkflowConfig 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 4 with WorkflowConfig

use of org.wso2.carbon.apimgt.core.models.WorkflowConfig in project carbon-apimgt by wso2.

the class WorkflowConfigHolder method loadWorkflowConfigurations.

private void loadWorkflowConfigurations(WorkflowExecutorInfo workflowConfig, String workflowExecutorType) throws ClassNotFoundException, IllegalAccessException, InstantiationException, WorkflowException {
    String executorClass = workflowConfig.getExecutor();
    Class clazz = WorkflowConfigHolder.class.getClassLoader().loadClass(executorClass);
    WorkflowExecutor workFlowExecutor = (WorkflowExecutor) clazz.newInstance();
    List<WorkflowConfigProperties> properties = workflowConfig.getProperty();
    if (properties != null) {
        loadProperties(properties, workFlowExecutor);
    }
    workflowExecutorMap.put(workflowExecutorType, workFlowExecutor);
}
Also used : WorkflowExecutor(org.wso2.carbon.apimgt.core.api.WorkflowExecutor) WorkflowConfigProperties(org.wso2.carbon.apimgt.core.models.WorkflowConfigProperties)

Example 5 with WorkflowConfig

use of org.wso2.carbon.apimgt.core.models.WorkflowConfig in project carbon-apimgt by wso2.

the class APIPublisherImplTestCase method init.

@BeforeClass
void init() {
    File temp = Files.createTempDir();
    temp.deleteOnExit();
    System.setProperty("gwHome", temp.getAbsolutePath());
    // Set the resource path, where contain composer test JS
    System.setProperty("carbon.home", new File("src/test/resources").getAbsolutePath());
    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;
        }
    });
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) ConfigProvider(org.wso2.carbon.config.provider.ConfigProvider) ConfigurationException(org.wso2.carbon.config.ConfigurationException) File(java.io.File) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

WorkflowConfig (org.wso2.carbon.apimgt.core.models.WorkflowConfig)5 ConfigurationException (org.wso2.carbon.config.ConfigurationException)3 ConfigProvider (org.wso2.carbon.config.provider.ConfigProvider)3 BeforeTest (org.testng.annotations.BeforeTest)2 File (java.io.File)1 BeforeClass (org.testng.annotations.BeforeClass)1 Test (org.testng.annotations.Test)1 WorkflowExecutor (org.wso2.carbon.apimgt.core.api.WorkflowExecutor)1 WorkflowException (org.wso2.carbon.apimgt.core.exception.WorkflowException)1 WorkflowConfigProperties (org.wso2.carbon.apimgt.core.models.WorkflowConfigProperties)1