Search in sources :

Example 16 with HistoricVariableInstance

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

the class TransientVariableTest method testStartMessageCorrelationWithTransientVariable.

@Test
public void testStartMessageCorrelationWithTransientVariable() {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().message("message").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', foo);").endEvent().done();
    testRule.deploy(instance);
    // when
    runtimeService.createMessageCorrelation("message").setVariable("foo", Variables.stringValue("bar", true)).correlate();
    // then
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    assertEquals(0, variableInstances.size());
    List<HistoricVariableInstance> historicInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(1, historicInstances.size());
    assertEquals("abc", historicInstances.get(0).getName());
    assertEquals("bar", historicInstances.get(0).getValue());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test)

Example 17 with HistoricVariableInstance

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

the class TransientVariableTest method createTransientVariablesUsingVariableMap.

@Test
public void createTransientVariablesUsingVariableMap() throws URISyntaxException {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().serviceTask().camundaClass(ReadTransientVariablesOfAllTypesDelegate.class.getName()).userTask("user").endEvent().done();
    testRule.deploy(instance);
    // when
    runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValue("a", Variables.stringValue("bar", true)).putValue("b", Variables.booleanValue(true, true)).putValue("c", Variables.byteArrayValue("test".getBytes(), true)).putValue("d", Variables.dateValue(new Date(), true)).putValue("e", Variables.doubleValue(20., true)).putValue("f", Variables.integerValue(10, true)).putValue("g", Variables.longValue((long) 10, true)).putValue("h", Variables.shortValue((short) 10, true)).putValue("i", Variables.objectValue(new Integer(100), true).create()).putValue("j", Variables.untypedValue(null, true)).putValue("k", Variables.untypedValue(Variables.booleanValue(true), true)).putValue("l", Variables.fileValue(new File(this.getClass().getClassLoader().getResource("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt").toURI()), true)));
    // then
    List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    assertEquals(0, historicVariableInstances.size());
    assertEquals(0, variableInstances.size());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 18 with HistoricVariableInstance

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

the class TransientVariableTest method createTransientVariablesUsingFluentBuilder.

@Test
public void createTransientVariablesUsingFluentBuilder() {
    // given
    BpmnModelInstance simpleInstanceWithListener = Bpmn.createExecutableProcess("Process").startEvent().camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadTransientVariableExecutionListener.class).userTask().endEvent().done();
    testRule.deploy(simpleInstanceWithListener);
    // when
    runtimeService.createProcessInstanceByKey("Process").setVariables(Variables.createVariables().putValue(VARIABLE_NAME, Variables.stringValue("dlsd", true))).execute();
    // then
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(0, variableInstances.size());
    assertEquals(0, historicVariableInstances.size());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test)

Example 19 with HistoricVariableInstance

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

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricProcessInstanceAsyncStartEvent.

@Deployment(resources = ASYNC_PROCESS)
public void testHistoricProcessInstanceAsyncStartEvent() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task2").setVariable("aVar", "aValue").execute();
    // then
    HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
    assertNotNull(historicInstance);
    assertEquals(instance.getId(), historicInstance.getId());
    assertNotNull(historicInstance.getStartTime());
    assertNull(historicInstance.getEndTime());
    // should be the first activity started
    assertEquals("task2", historicInstance.getStartActivityId());
    // task2 wasn't entered yet
    assertEquals(0, historyService.createHistoricActivityInstanceQuery().count());
    // history events for variables exist already
    ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
    HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult();
    assertNotNull(historicVariable);
    assertEquals(instance.getId(), historicVariable.getProcessInstanceId());
    assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId());
    assertEquals("aVar", historicVariable.getName());
    assertEquals("aValue", historicVariable.getValue());
    HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.getId()).singleResult();
    assertEquals(instance.getId(), historicDetail.getProcessInstanceId());
    assertNotNull(historicDetail);
    // TODO: fix if this is not ok due to CAM-3886
    assertNull(historicDetail.getActivityInstanceId());
    assertTrue(historicDetail instanceof HistoricVariableUpdate);
    assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName());
    assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue());
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 20 with HistoricVariableInstance

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

the class ModifyVariableInSameTransactionTest method testInsertDeleteInsertTheSameVariable.

@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testInsertDeleteInsertTheSameVariable() {
    BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("serviceTaskProcess").startEvent().userTask("userTask").serviceTask("service").camundaClass(InsertDeleteInsertVariableDelegate.class).userTask("userTask1").endEvent().done();
    ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(bpmnModel);
    VariableMap variables = Variables.createVariables().putValue("listVar", Arrays.asList(new int[] { 1, 2, 3 }));
    ProcessInstance instance = engineRule.getRuntimeService().startProcessInstanceById(processDefinition.getId(), variables);
    Task task = engineRule.getTaskService().createTaskQuery().singleResult();
    engineRule.getTaskService().complete(task.getId());
    VariableInstance variable = engineRule.getRuntimeService().createVariableInstanceQuery().processInstanceIdIn(instance.getId()).variableName("foo").singleResult();
    assertNotNull(variable);
    assertEquals("bar", variable.getValue());
    List<HistoricVariableInstance> historyVariables = engineRule.getHistoryService().createHistoricVariableInstanceQuery().list();
    for (HistoricVariableInstance historicVariable : historyVariables) {
        if (variable.getName().equals(historicVariable.getName())) {
            assertEquals(HistoricVariableInstance.STATE_CREATED, historicVariable.getState());
            break;
        }
    }
}
Also used : Task(org.camunda.bpm.engine.task.Task) VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)88 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)44 Test (org.junit.Test)42 Deployment (org.camunda.bpm.engine.test.Deployment)39 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)18 Task (org.camunda.bpm.engine.task.Task)17 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)12 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)10 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)10 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)10 HashMap (java.util.HashMap)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)8 VariableMap (org.camunda.bpm.engine.variable.VariableMap)8 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)7 Date (java.util.Date)6 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 MockHistoricVariableInstanceBuilder (org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder)6