Search in sources :

Example 26 with Deployment

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

the class EventNotificationTest method testMultiInstanceEventsAfterExternalTrigger.

@Test
@Deployment
public void testMultiInstanceEventsAfterExternalTrigger() {
    runtimeService.startProcessInstanceByKey("process");
    TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
    listenerBean.reset();
    List<Task> tasks = taskService.createTaskQuery().list();
    assertEquals(3, tasks.size());
    for (Task task : tasks) {
        taskService.complete(task.getId());
    }
    // 6: three user task instances (complete + end)
    // 1: one mi body instance (end)
    // 1: one sequence flow instance (take)
    // 2: one end event instance (start + end)
    // = 5
    Set<BusinessProcessEvent> eventsReceived = listenerBean.getEventsReceived();
    assertThat(eventsReceived.size(), is(10));
}
Also used : Task(org.camunda.bpm.engine.task.Task) BusinessProcessEvent(org.camunda.bpm.engine.cdi.BusinessProcessEvent) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 27 with Deployment

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

the class EventNotificationTest method testMultiInstanceEvents.

@Test
@Deployment
public void testMultiInstanceEvents() {
    TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
    listenerBean.reset();
    assertThat(listenerBean.getEventsReceived().size(), is(0));
    runtimeService.startProcessInstanceByKey("process1");
    waitForJobExecutorToProcessAllJobs(TimeUnit.SECONDS.toMillis(5L), 500L);
    Task task = taskService.createTaskQuery().singleResult();
    assertThat(task.getName(), is("User Task"));
    // 2: start event (start + end)
    // 1: transition to first mi activity
    // 2: first mi body (start + end)
    // 4: two instances of the inner activity (start + end)
    // 1: transition to second mi activity
    // 2: second mi body (start + end)
    // 4: two instances of the inner activity (start + end)
    // 1: transition to the user task
    // 2: user task (start + task create event)
    // = 19
    assertThat(listenerBean.getEventsReceived().size(), is(19));
}
Also used : Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 28 with Deployment

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

the class EventNotificationTest method testReceiveAll.

@Test
@Deployment(resources = { "org/camunda/bpm/engine/cdi/test/impl/event/EventNotificationTest.process1.bpmn20.xml" })
public void testReceiveAll() {
    TestEventListener listenerBean = getBeanInstance(TestEventListener.class);
    listenerBean.reset();
    // assert that the bean has received 0 events
    assertEquals(0, listenerBean.getEventsReceived().size());
    runtimeService.startProcessInstanceByKey("process1");
    // complete user task
    Task task = taskService.createTaskQuery().singleResult();
    taskService.complete(task.getId());
    assertEquals(16, listenerBean.getEventsReceived().size());
}
Also used : Task(org.camunda.bpm.engine.task.Task) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 29 with Deployment

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

the class HistoricDecisionInstanceSerializationTest method testListJsonProperty.

@Deployment(resources = { "org/camunda/spin/plugin/DecisionSingleOutput.dmn11.xml" })
public void testListJsonProperty() {
    JsonListSerializable<String> list = new JsonListSerializable<String>();
    list.addElement("foo");
    ObjectValue objectValue = Variables.objectValue(list).serializationDataFormat(DataFormats.JSON_DATAFORMAT_NAME).create();
    VariableMap variables = Variables.createVariables().putValueTyped("input1", objectValue);
    decisionService.evaluateDecisionTableByKey("testDecision", variables);
    HistoricDecisionInstance testDecision = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey("testDecision").includeInputs().includeOutputs().singleResult();
    assertNotNull(testDecision);
    List<HistoricDecisionInputInstance> inputs = testDecision.getInputs();
    assertEquals(1, inputs.size());
    HistoricDecisionInputInstance inputInstance = inputs.get(0);
    assertEquals(list.getListProperty(), inputInstance.getValue());
    List<HistoricDecisionOutputInstance> outputs = testDecision.getOutputs();
    assertEquals(1, outputs.size());
    HistoricDecisionOutputInstance outputInstance = outputs.get(0);
    assertEquals(list.getListProperty(), outputInstance.getValue());
}
Also used : HistoricDecisionInputInstance(org.camunda.bpm.engine.history.HistoricDecisionInputInstance) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionOutputInstance(org.camunda.bpm.engine.history.HistoricDecisionOutputInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 30 with Deployment

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

the class HistoricVariableJsonSerializationTest method testSelectHistoricSerializedValuesUpdate.

@Deployment(resources = ONE_TASK_PROCESS)
public void testSelectHistoricSerializedValuesUpdate() throws JSONException {
    ProcessInstance instance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    JsonSerializable bean = new JsonSerializable("a String", 42, false);
    runtimeService.setVariable(instance.getId(), "simpleBean", objectValue(bean).serializationDataFormat(JSON_FORMAT_NAME));
    if (ProcessEngineConfiguration.HISTORY_FULL.equals(processEngineConfiguration.getHistory())) {
        HistoricVariableUpdate historicUpdate = (HistoricVariableUpdate) historyService.createHistoricDetailQuery().variableUpdates().singleResult();
        assertNotNull(historicUpdate.getValue());
        assertNull(historicUpdate.getErrorMessage());
        assertEquals(ValueType.OBJECT.getName(), historicUpdate.getTypeName());
        assertEquals(ValueType.OBJECT.getName(), historicUpdate.getVariableTypeName());
        JsonSerializable historyValue = (JsonSerializable) historicUpdate.getValue();
        assertEquals(bean.getStringProperty(), historyValue.getStringProperty());
        assertEquals(bean.getIntProperty(), historyValue.getIntProperty());
        assertEquals(bean.getBooleanProperty(), historyValue.getBooleanProperty());
        ObjectValue typedValue = (ObjectValue) historicUpdate.getTypedValue();
        assertEquals(JSON_FORMAT_NAME, typedValue.getSerializationDataFormat());
        JSONAssert.assertEquals(bean.toExpectedJsonString(), new String(typedValue.getValueSerialized()), true);
        assertEquals(JsonSerializable.class.getName(), typedValue.getObjectTypeName());
    }
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) ObjectValue(org.camunda.bpm.engine.variable.value.ObjectValue) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Deployment (org.camunda.bpm.engine.test.Deployment)3376 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1325 Task (org.camunda.bpm.engine.task.Task)788 Test (org.junit.Test)635 HashMap (java.util.HashMap)441 Job (org.camunda.bpm.engine.runtime.Job)310 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)277 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)265 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)256 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)251 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)230 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)206 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)195 Execution (org.camunda.bpm.engine.runtime.Execution)189 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)175 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)161 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)149 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)143 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)134 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)134