Search in sources :

Example 46 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class JobMigrationScenario method triggerEntryCriterion.

@DescribesScenario("createJob")
public static ScenarioSetup triggerEntryCriterion() {
    return new ScenarioSetup() {

        public void execute(ProcessEngine engine, final String scenarioName) {
            final ProcessEngineConfigurationImpl engineConfiguration = (ProcessEngineConfigurationImpl) engine.getProcessEngineConfiguration();
            CommandExecutor commandExecutor = engineConfiguration.getCommandExecutorTxRequired();
            // create a job with the scenario name as id and a null suspension state
            commandExecutor.execute(new Command<Void>() {

                public Void execute(CommandContext commandContext) {
                    Connection connection = null;
                    Statement statement = null;
                    ResultSet rs = null;
                    try {
                        SqlSession sqlSession = commandContext.getDbSqlSession().getSqlSession();
                        connection = sqlSession.getConnection();
                        statement = connection.createStatement();
                        statement.executeUpdate("INSERT INTO ACT_RU_JOB(ID_, REV_, RETRIES_, TYPE_, EXCLUSIVE_, HANDLER_TYPE_) " + "VALUES (" + "'" + scenarioName + "'," + "1," + "3," + "'timer'," + DbSqlSessionFactory.databaseSpecificTrueConstant.get(engineConfiguration.getDatabaseType()) + "," + "'" + TimerStartEventJobHandler.TYPE + "'" + ")");
                        connection.commit();
                        statement.close();
                    } catch (SQLException e) {
                        throw new RuntimeException(e);
                    } finally {
                        try {
                            if (statement != null) {
                                statement.close();
                            }
                            if (rs != null) {
                                rs.close();
                            }
                            if (connection != null) {
                                connection.close();
                            }
                        } catch (SQLException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    return null;
                }
            });
        }
    };
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) SqlSession(org.apache.ibatis.session.SqlSession) SQLException(java.sql.SQLException) Statement(java.sql.Statement) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) Connection(java.sql.Connection) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ResultSet(java.sql.ResultSet) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario)

Example 47 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ProcessWithParallelGatewayScenario method startProcessCompleteTwoUserTask.

@DescribesScenario("init.complete.two")
@Times(1)
public static ScenarioSetup startProcessCompleteTwoUserTask() {
    return new ScenarioSetup() {

        @Override
        public void execute(ProcessEngine engine, String scenarioName) {
            ProcessInstance procInst = engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
            List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(procInst.getId()).list();
            for (Task task : tasks) {
                engine.getTaskService().complete(task.getId());
            }
        }
    };
}
Also used : Task(org.camunda.bpm.engine.task.Task) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario) Times(org.camunda.bpm.qa.upgrade.Times)

Example 48 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ProcessWithParallelGatewayScenario method startProcessCompleteOneUserTask.

@DescribesScenario("init.complete.one")
@Times(1)
public static ScenarioSetup startProcessCompleteOneUserTask() {
    return new ScenarioSetup() {

        @Override
        public void execute(ProcessEngine engine, String scenarioName) {
            ProcessInstance procInst = engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
            List<Task> tasks = engine.getTaskService().createTaskQuery().processInstanceId(procInst.getId()).list();
            if (tasks.size() > 0) {
                engine.getTaskService().complete(tasks.get(0).getId());
            }
        }
    };
}
Also used : Task(org.camunda.bpm.engine.task.Task) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario) Times(org.camunda.bpm.qa.upgrade.Times)

Example 49 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ProcessWithCallActivityScenario method startProcessAndCompleteFirstTask.

@DescribesScenario("init.complete.one")
@Times(1)
public static ScenarioSetup startProcessAndCompleteFirstTask() {
    return new ScenarioSetup() {

        public void execute(ProcessEngine engine, String scenarioName) {
            ProcessInstance procInst = engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
            Task task = engine.getTaskService().createTaskQuery().processInstanceId(procInst.getId()).singleResult();
            engine.getTaskService().complete(task.getId());
        }
    };
}
Also used : Task(org.camunda.bpm.engine.task.Task) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario) Times(org.camunda.bpm.qa.upgrade.Times)

Example 50 with ProcessEngine

use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.

the class ProcessWithEventSubProcessScenario method startProcessWithThrowedBpmnError.

@DescribesScenario("init.error")
@Times(1)
public static ScenarioSetup startProcessWithThrowedBpmnError() {
    return new ScenarioSetup() {

        @Override
        public void execute(ProcessEngine engine, String scenarioName) {
            ProcessInstance procInstance = engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY, scenarioName);
            Job job = engine.getManagementService().createJobQuery().processInstanceId(procInstance.getId()).singleResult();
            engine.getManagementService().executeJob(job.getId());
        }
    };
}
Also used : ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario) Times(org.camunda.bpm.qa.upgrade.Times)

Aggregations

ProcessEngine (org.camunda.bpm.engine.ProcessEngine)162 DescribesScenario (org.camunda.bpm.qa.upgrade.DescribesScenario)60 ScenarioSetup (org.camunda.bpm.qa.upgrade.ScenarioSetup)60 Task (org.camunda.bpm.engine.task.Task)52 Times (org.camunda.bpm.qa.upgrade.Times)52 Test (org.junit.Test)26 ExtendsScenario (org.camunda.bpm.qa.upgrade.ExtendsScenario)18 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)17 ArrayList (java.util.ArrayList)16 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)15 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)14 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)14 RepositoryService (org.camunda.bpm.engine.RepositoryService)13 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)7 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 Job (org.camunda.bpm.engine.runtime.Job)5 Connection (java.sql.Connection)4 CaseService (org.camunda.bpm.engine.CaseService)4 StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)4