Search in sources :

Example 51 with ProcessEngine

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

the class ProcessWithParallelGatewayAndServiceTaskScenario method startProcessAsyncServiceTaskCompleteUserTask.

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

        @Override
        public void execute(ProcessEngine engine, String scenarioName) {
            ProcessInstance procInst = engine.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY_2, 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 52 with ProcessEngine

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

the class CreateProcessInstanceWithJsonVariablesScenario method initProcessInstance.

@DescribesScenario("initProcessInstanceWithDifferentVariables")
public static ScenarioSetup initProcessInstance() {
    return new ScenarioSetup() {

        public void execute(ProcessEngine engine, String scenarioName) {
            // given
            ProcessInstance processInstance = engine.getRuntimeService().startProcessInstanceByKey("Process", "processWithJsonVariables");
            // when
            Execution execution = engine.getRuntimeService().createExecutionQuery().processInstanceId(processInstance.getId()).singleResult();
            engine.getRuntimeService().setVariable(execution.getId(), "objectVariable", createObjectVariable());
            engine.getRuntimeService().setVariable(execution.getId(), "plainTypeArrayVariable", createPlainTypeArray());
            engine.getRuntimeService().setVariable(execution.getId(), "notGenericObjectListVariable", createNotGenericObjectList());
            engine.getRuntimeService().setVariable(execution.getId(), "serializedMapVariable", createSerializedMap());
        }
    };
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) 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)

Example 53 with ProcessEngine

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

the class DbSchemaPrefixTestHelper method afterPropertiesSet.

public void afterPropertiesSet() throws Exception {
    dataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000;MVCC=TRUE;", "sa", "");
    // create schema in the
    Connection connection = dataSource.getConnection();
    connection.createStatement().execute("drop schema if exists SCHEMA1");
    connection.createStatement().execute("create schema SCHEMA1");
    connection.close();
    ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1").setDataSource(dataSource).setDbMetricsReporterActivate(false).setDatabaseSchemaUpdate(// disable auto create/drop schema
    "NO_CHECK");
    config1.setDatabaseTablePrefix("SCHEMA1.");
    ProcessEngine engine1 = config1.buildProcessEngine();
    // create the tables in SCHEMA1
    connection = dataSource.getConnection();
    connection.createStatement().execute("set schema SCHEMA1");
    engine1.getManagementService().databaseSchemaUpgrade(connection, "", "SCHEMA1");
    connection.close();
    engine1.close();
}
Also used : Connection(java.sql.Connection) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) PooledDataSource(org.apache.ibatis.datasource.pooled.PooledDataSource) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 54 with ProcessEngine

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

the class EnsureCleanDbPlugin method postProcessApplicationUndeploy.

@SuppressWarnings("resource")
@Override
public void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication) {
    // best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
    if (counter.get() == 0 || counter.decrementAndGet() == 0) {
        final ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
        try {
            logger.log(Level.INFO, "=== Ensure Clean Database ===");
            ManagementServiceImpl managementService = (ManagementServiceImpl) defaultProcessEngine.getManagementService();
            PurgeReport report = managementService.purge();
            if (report.isEmpty()) {
                logger.log(Level.INFO, "Clean DB and cache.");
            } else {
                StringBuilder builder = new StringBuilder();
                DatabasePurgeReport databasePurgeReport = report.getDatabasePurgeReport();
                if (!databasePurgeReport.isEmpty()) {
                    builder.append(DATABASE_NOT_CLEAN).append(databasePurgeReport.getPurgeReportAsString());
                }
                CachePurgeReport cachePurgeReport = report.getCachePurgeReport();
                if (!cachePurgeReport.isEmpty()) {
                    builder.append(CACHE_IS_NOT_CLEAN).append(cachePurgeReport.getPurgeReportAsString());
                }
                logger.log(Level.INFO, builder.toString());
            }
        } catch (Throwable e) {
            logger.log(Level.SEVERE, "Could not clean DB:", e);
        }
    }
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 55 with ProcessEngine

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

the class SequentialMultiInstanceCompensationScenario method defaultHandlerThrowCompensate.

@DescribesScenario("defaultHandler.beforeCompensate.throwCompensate")
@ExtendsScenario("defaultHandler.beforeCompensate")
@Times(3)
public static ScenarioSetup defaultHandlerThrowCompensate() {
    return new ScenarioSetup() {

        public void execute(ProcessEngine engine, String scenarioName) {
            Task beforeCompensateTask = engine.getTaskService().createTaskQuery().processInstanceBusinessKey(scenarioName).singleResult();
            engine.getTaskService().complete(beforeCompensateTask.getId());
        }
    };
}
Also used : Task(org.camunda.bpm.engine.task.Task) ScenarioSetup(org.camunda.bpm.qa.upgrade.ScenarioSetup) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DescribesScenario(org.camunda.bpm.qa.upgrade.DescribesScenario) Times(org.camunda.bpm.qa.upgrade.Times) ExtendsScenario(org.camunda.bpm.qa.upgrade.ExtendsScenario)

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