Package org.activiti.engine

Examples of org.activiti.engine.RuntimeService


   
    ProcessInstance processInstance = formService.submitStartFormData(processDefinition.getId(), formProperties);
    assertNotNull(processInstance);
   
    // 运行时变量
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variables = runtimeService.getVariables(processInstance.getId());
    assertEquals(variables.size(), 1);
    Set<Entry<String, Object>> entrySet = variables.entrySet();
    for (Entry<String, Object> entry : entrySet) {
      System.out.println(entry.getKey() + "=" + entry.getValue());
    }
View Full Code Here


public abstract class CheckProcessesTest {

    protected RuntimeService mockRuntimeService(Map<String, ProcessInstance> instances,
                                              String... notFoundProcessInstanceIds) {
        RuntimeService runtimeService = mock(RuntimeService.class);

        ProcessInstanceQuery generalQuery = mock(ProcessInstanceQuery.class);
        for (Map.Entry<String, ProcessInstance> entry : instances.entrySet()) {
            ProcessInstanceQuery specificQuery = mock(ProcessInstanceQuery.class);
            when(specificQuery.singleResult()).thenReturn(entry.getValue());

            when(generalQuery.processInstanceId(eq(entry.getKey()))).thenReturn(specificQuery);
        }
        for (String notFound : notFoundProcessInstanceIds) {
            /* create a mock that returns null for all method calls (default) */
            when(generalQuery.processInstanceId(eq(notFound))).thenReturn(mock(ProcessInstanceQuery.class));
        }
        when(runtimeService.createProcessInstanceQuery()).thenReturn(generalQuery);

        return runtimeService;
    }
View Full Code Here

    private static final String PROCESS_IDS = "process_ids";

    @Test
    public void testWithAListOfEndedProcesses() throws Exception {
        RuntimeService runtimeService = runTest(Lists.newArrayList("1", "2"), ImmutableMap.of(
            "1", mockProcessInstance(/* ended= */ true),
            "2", mockProcessInstance(/* ended= */ true)
        ));
        verify(runtimeService, never()).deleteProcessInstance(anyString(), anyString());
    }
View Full Code Here

        verify(runtimeService, never()).deleteProcessInstance(anyString(), anyString());
    }

    @Test
    public void testWithAListOfActiveProcesses() throws Exception {
        RuntimeService runtimeService = runTest(Lists.newArrayList("1", "2"), ImmutableMap.of(
            "1", mockProcessInstance(/* ended= */ false),
            "2", mockProcessInstance(/* ended= */ false)
        ));
        verify(runtimeService, times(2)).deleteProcessInstance(anyString(), anyString());
    }
View Full Code Here

        verify(runtimeService, times(2)).deleteProcessInstance(anyString(), anyString());
    }

    @Test
    public void testWithAListOfActiveAndInactiveProcesses() throws Exception {
        RuntimeService runtimeService = runTest(Lists.newArrayList("1", "2"), ImmutableMap.of(
            "1", mockProcessInstance(/* ended= */ true),
            "2", mockProcessInstance(/* ended= */ false)
        ));

        verify(runtimeService, times(1)).deleteProcessInstance(anyString(), anyString());
View Full Code Here

        verify(runtimeService, times(1)).deleteProcessInstance(anyString(), anyString());
    }

    @Test
    public void testWithAListOfActiveAndInvalidProcesses() throws Exception {
        RuntimeService runtimeService = runTest(Lists.newArrayList("1", "invalid"), ImmutableMap.of(
            "1", mockProcessInstance(/* ended= */ false)));
        verify(runtimeService, times(1)).deleteProcessInstance(anyString(), anyString());
    }
View Full Code Here

        when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(processIds);

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

        RuntimeService runtimeService = mockRuntimeService(processMap, "invalid");

        JavaDelegate delegate = new KillMachineSetUpProcesses(runtimeService, PROCESS_IDS);
        delegate.execute(execution);

        return runtimeService;
View Full Code Here

     *
     * @see <a href="http://www.activiti.org/userguide/index.html#bpmnSignalEventDefinition" />
     * @see CoreSignals
     */
    protected void triggerSignalEvent(ProcessEngine processEngine, String businessKey, String signalName) {
        RuntimeService runtimeService = processEngine.getRuntimeService();

        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
            .processInstanceBusinessKey(businessKey).singleResult();

        List<Execution> executions = runtimeService.createExecutionQuery()
            .processInstanceId(processInstance.getProcessInstanceId())
            .signalEventSubscriptionName(signalName).list();

        if (executions.isEmpty()) {
            throw new NoSuchElementException(String.format("No executions found waiting " +
                "for signal '%s' on process %s", signalName, businessKey));
        }
        for (Execution execution : executions) {
            LOG.info("Sending '{}' signal to execution {} for process {}",
                new Object[]{signalName, execution.getId(), businessKey});
            runtimeService.signalEventReceived(signalName, execution.getId());

        }
    }
View Full Code Here

        when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(Lists.newArrayList("1", "2"));

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

        RuntimeService runtimeService = mockRuntimeService(ImmutableMap.of(
            "1", mockProcessInstance(/* ended= */ true),
            "2", mockProcessInstance(/* ended= */ true)
        ));

        JavaDelegate delegate = new CheckProcessesEnded(runtimeService, PROCESS_IDS, RESULT);
View Full Code Here

        when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(Lists.newArrayList("1", "2"));

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

        RuntimeService runtimeService = mockRuntimeService(ImmutableMap.of(
            "1", mockProcessInstance(/* ended= */ true),
            "2", mockProcessInstance(/* ended= */ false)
        ));

        JavaDelegate delegate = new CheckProcessesEnded(runtimeService, PROCESS_IDS, RESULT);
View Full Code Here

TOP

Related Classes of org.activiti.engine.RuntimeService

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.