Package org.activiti.engine

Examples of org.activiti.engine.ProcessEngine


    public void testListProcess() throws Exception {
        final List<ProcessInstance> processes = ImmutableList.of(
            newProcessInstanceMock("p1", "k1"),
            newProcessInstanceMock("p2", "k2")
        );
        final ProcessEngine processEngine = newProcessEngineMock(processes);

        Pool pool = mock(Pool.class);
        setVariable(processEngine, "p1", CoreProcessVariables.POOL, pool);
        setVariable(processEngine, "p1", CoreProcessVariables.POOL_BUSINESS_KEY, "k1");
View Full Code Here


        when(runtimeService.getVariable(instanceId, key)).thenReturn(value);
    }

    private ProcessEngine newProcessEngineMock(List<ProcessInstance> instances) {
        ProcessEngine processEngine = mock(ProcessEngine.class);

        RuntimeService runtimeService = mock(RuntimeService.class);
        when(processEngine.getRuntimeService()).thenReturn(runtimeService);

        ProcessInstanceQuery allInstancesQuery = mock(ProcessInstanceQuery.class);
        when(allInstancesQuery.list()).thenReturn(instances);
        when(runtimeService.createProcessInstanceQuery()).thenReturn(allInstancesQuery);
View Full Code Here

        out.flush();
        assertThat(outputStream.toString()).containsIgnoringCase("please supply a business key");
    }

    private ProcessEngine newMockProcessEngine() {
        final ProcessEngine engine = mock(ProcessEngine.class);
        final List<ProcessInstance> processes = ImmutableList.of(
            newProcessInstanceMock("p1", BUSINESS_KEY, true),
            newProcessInstanceMock("p2", BUSINESS_KEY, false),
            newProcessInstanceMock("p3", BUSINESS_KEY, true)
        );

        final RuntimeService runtimeService = mock(RuntimeService.class);
        final ProcessInstanceQuery processInstanceQuery = mock(ProcessInstanceQuery.class);

        when(engine.getRuntimeService()).thenReturn(runtimeService);
        when(runtimeService.createProcessInstanceQuery()).thenReturn(processInstanceQuery);
        when(processInstanceQuery.variableValueEquals(CoreProcessVariables.POOL_BUSINESS_KEY, BUSINESS_KEY))
            .thenReturn(processInstanceQuery);
        when(processInstanceQuery.orderByProcessInstanceId()).thenReturn(processInstanceQuery);
        when(processInstanceQuery.desc()).thenReturn(processInstanceQuery);
View Full Code Here

     *
     * @param processKey
     * @throws InterruptedException
     */
    public void waitForProcessDeployment(String processKey) throws InterruptedException, TimeoutException {
        ProcessEngine engine = getOsgiService(ProcessEngine.class, 5000);
        int iteration = 0;
        while (iteration < 5) {
            ProcessDefinition definition = engine.getRepositoryService()
                .createProcessDefinitionQuery()
                .processDefinitionKey(processKey).singleResult();
            if (definition != null) {
                break;
            }
View Full Code Here

        ProcessInstance localInstance = getProcessInstanceById(processInstanceId);
        return localInstance != null && !localInstance.isEnded();
    }

    private ProcessInstance getProcessInstanceById(final String processInstanceId) throws InterruptedException {
        ProcessEngine engine = getOsgiService(ProcessEngine.class, 5000);
        return engine.getRuntimeService().createProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .singleResult();
    }
View Full Code Here

        multiValued = true, description = "Signal all activities in a process instances")
    private String[] activities;

    @Override
    protected Object doExecute() throws Exception {
        ProcessEngine engine = this.getProcessEngine();
        if (engine == null) {
            out().println("Process Engine NOT Found!");
            return null;
        }
        RuntimeService runtimeService = engine.getRuntimeService();

        if (this.instanceIDs != null && this.instanceIDs.length > 0) {
            for (String instanceID : this.instanceIDs) {
                signal(runtimeService, instanceID, this.activities);
            }
View Full Code Here

        when(execution.getVariable(eq(CoreProcessVariables.MACHINES))).thenReturn(machines);

        ProcessVariablesCollector collector = new ProcessVariablesCollector();
        collector.install(execution);

        ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration()
            .setJobExecutorActivate(true).buildProcessEngine();
        processEngine.getRepositoryService().createDeployment()
            .addClasspathResource("diagrams/empty.bpmn20.xml").deploy();

        try {
            JavaDelegate delegate = new SpawnProcessForEachMachine(processEngine, EMPTY_PROCESS_KEY, "test", RESULT);
            delegate.execute(execution);

            @SuppressWarnings("unchecked")
            List<String> processInstanceIds = (List<String>) collector.getVariable(RESULT);

            assertThat(processInstanceIds).hasSize(2);

        } finally {
            processEngine.close();
        }
    }
View Full Code Here

        jobExecutor.setQueueSize(2);
        jobExecutor.setMaxJobsPerAcquisition(5);
        jobExecutor.setWaitTimeInMillis(50);
        jobExecutor.setLockTimeInMillis(180000);

        ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration()
            .setJobExecutorActivate(true)
            .setJobExecutor(jobExecutor)
            .setFailedJobCommandFactory(new ConfigurableFailedJobCommandFactory(2, 1))
            .buildProcessEngine();

        processEngine.getRepositoryService().createDeployment()
            .addClasspathResource("diagrams/alwaysFail.bpmn20.xml").deploy();

        Stopwatch stopwatch = new Stopwatch().start();
        processEngine.getRuntimeService().startProcessInstanceByKey("alwaysFail");

        while (AlwaysFailTask.COUNTER.get() != 3 /* = 1 normal execution + 2 retries */) {
            TimeUnit.MILLISECONDS.sleep(100);
        }

        stopwatch.stop();
        assertThat(stopwatch.elapsedTime(TimeUnit.SECONDS)).isGreaterThanOrEqualTo(2);

        processEngine.close();
    }
View Full Code Here

TOP

Related Classes of org.activiti.engine.ProcessEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.