Search in sources :

Example 6 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class ReplayRunTest method testProcessInstanceStartEvents.

@Test
public void testProcessInstanceStartEvents() throws Exception {
    ProcessEngineImpl processEngine = initProcessEngine();
    TaskService taskService = processEngine.getTaskService();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(TEST_VARIABLE, TEST_VALUE);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(USERTASK_PROCESS, BUSINESS_KEY, variables);
    Task task = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
    TimeUnit.MILLISECONDS.sleep(50);
    taskService.complete(task.getId());
    final SimulationDebugger simRun = new ReplaySimulationRun(processEngine, getReplayHandlers(processInstance.getId()));
    simRun.init(new NoExecutionVariableScope());
    // original process is finished - there should not be any running process instance/task
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    simRun.step();
    // replay process was started
    assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    // there should be one task
    assertEquals(1, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    simRun.step();
    // userTask was completed - replay process was finished
    assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey(USERTASK_PROCESS).count());
    assertEquals(0, taskService.createTaskQuery().taskDefinitionKey("userTask").count());
    simRun.close();
    processEngine.close();
    ProcessEngines.destroy();
}
Also used : ReplaySimulationRun(org.activiti.crystalball.simulator.ReplaySimulationRun) Task(org.activiti.engine.task.Task) RuntimeService(org.activiti.engine.RuntimeService) TaskService(org.activiti.engine.TaskService) SimulationDebugger(org.activiti.crystalball.simulator.SimulationDebugger) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl) Test(org.junit.Test)

Example 7 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class EventRecorderTestUtils method closeProcessEngine.

public static void closeProcessEngine(ProcessEngine processEngine, ActivitiEventListener listener) {
    if (listener != null) {
        final ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
        processEngineConfiguration.getEventDispatcher().removeEventListener(listener);
    }
    processEngine.close();
}
Also used : ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 8 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class AbstractPlaybackTest method runPlayback.

private void runPlayback() throws Throwable {
    SimulationDebugger simDebugger = null;
    try {
        // init simulation run
        Clock clock = new ThreadLocalClock(new DefaultClockFactory());
        FactoryBean<ProcessEngineImpl> simulationProcessEngineFactory = new SimulationProcessEngineFactory(ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault());
        final SimpleSimulationRun.Builder builder = new SimpleSimulationRun.Builder();
        builder.processEngine(simulationProcessEngineFactory.getObject()).eventCalendar((new SimpleEventCalendarFactory(clock, new SimulationEventComparator(), listener.getSimulationEvents())).getObject()).eventHandlers(getHandlers());
        simDebugger = builder.build();
        simDebugger.init(new NoExecutionVariableScope());
        this.processEngine = SimulationRunContext.getProcessEngine();
        initializeServices();
        deploymentIdFromDeploymentAnnotation = TestHelper.annotationDeploymentSetUp(processEngine, getClass(), getName());
        simDebugger.runContinue();
        _checkStatus();
    } catch (AssertionFailedError e) {
        log.warn("Playback simulation {} has failed", getName());
        log.error(EMPTY_LINE);
        log.error("ASSERTION FAILED: {}", e, e);
        exception = e;
        throw e;
    } catch (Throwable e) {
        log.warn("Playback simulation {} has failed", getName());
        log.error(EMPTY_LINE);
        log.error("EXCEPTION: {}", e, e);
        exception = e;
        throw e;
    } finally {
        if (simDebugger != null) {
            TestHelper.annotationDeploymentTearDown(processEngine, deploymentIdFromDeploymentAnnotation, getClass(), getName());
            simDebugger.close();
            assertAndEnsureCleanDb();
        }
        this.processEngineConfiguration.getClock().reset();
        // Can't do this in the teardown, as the teardown will be called as part of the super.runBare
        closeDownProcessEngine();
    }
}
Also used : NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) Clock(org.activiti.engine.runtime.Clock) DefaultClockFactory(org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory) SimulationProcessEngineFactory(org.activiti.crystalball.simulator.impl.SimulationProcessEngineFactory) AssertionFailedError(junit.framework.AssertionFailedError) ThreadLocalClock(org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 9 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class DbSchemaUpdate method main.

public static void main(String[] args) {
    ProcessEngineImpl processEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
    CommandExecutor commandExecutor = processEngine.getProcessEngineConfiguration().getCommandExecutor();
    CommandConfig config = new CommandConfig().transactionNotSupported();
    commandExecutor.execute(config, new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            commandContext.getSession(DbSqlSession.class).dbSchemaUpdate();
            return null;
        }
    });
}
Also used : CommandConfig(org.activiti.engine.impl.interceptor.CommandConfig) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Example 10 with ProcessEngineImpl

use of org.activiti.engine.impl.ProcessEngineImpl in project Activiti by Activiti.

the class ReplayEventLogTest method initProcessEngine.

private ProcessEngineImpl initProcessEngine() {
    ProcessEngineConfigurationImpl configuration = getProcessEngineConfiguration();
    ProcessEngineImpl processEngine = (ProcessEngineImpl) configuration.buildProcessEngine();
    processEngine.getRepositoryService().createDeployment().addClasspathResource(THE_USERTASK_PROCESS).deploy();
    return processEngine;
}
Also used : ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl)

Aggregations

ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)14 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)4 NoExecutionVariableScope (org.activiti.engine.impl.el.NoExecutionVariableScope)4 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)3 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)3 ProcessDiagramGenerator (org.activiti.image.ProcessDiagramGenerator)3 Test (org.junit.Test)3 StreamResource (com.vaadin.terminal.StreamResource)2 Embedded (com.vaadin.ui.Embedded)2 HashMap (java.util.HashMap)2 ReplaySimulationRun (org.activiti.crystalball.simulator.ReplaySimulationRun)2 SimulationDebugger (org.activiti.crystalball.simulator.SimulationDebugger)2 DefaultClockFactory (org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory)2 ThreadLocalClock (org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock)2 ActivitiException (org.activiti.engine.ActivitiException)2 RuntimeService (org.activiti.engine.RuntimeService)2 TaskService (org.activiti.engine.TaskService)2 CommandConfig (org.activiti.engine.impl.interceptor.CommandConfig)2 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)2