Search in sources :

Example 76 with HistoricVariableInstance

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

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricVariableInstanceSetOnProcessInstance.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricVariableInstanceSetOnProcessInstance() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").setVariable("aVar", "aValue").startBeforeActivity("task1").execute();
    ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
    // then
    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
    assertEquals(instance.getId(), 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) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 77 with HistoricVariableInstance

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

the class TransientVariableTest method testSignalWithTransientVariables.

@Test
public void testSignalWithTransientVariables() {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().intermediateCatchEvent("signalCatch").signal("signal").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', foo);").endEvent().done();
    testRule.deploy(instance);
    runtimeService.startProcessInstanceByKey("Process");
    // when
    runtimeService.signalEventReceived("signal", Variables.createVariables().putValue("foo", Variables.stringValue("bar", true)));
    // then
    List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(1, variables.size());
    assertEquals("abc", variables.get(0).getName());
}
Also used : HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 78 with HistoricVariableInstance

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

the class TransientVariableTest method testParallelExecutions.

@Test
public void testParallelExecutions() {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("Process").startEvent().parallelGateway().scriptTask().scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariableLocal('abc', foo);").endEvent().moveToLastGateway().scriptTask().scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariableLocal('abc', foo);").endEvent().done();
    testRule.deploy(instance);
    // when
    runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValueTyped("foo", Variables.stringValue("bar", true)));
    // then
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().list();
    assertEquals(0, variables.size());
    List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().variableName("abc").list();
    assertEquals(2, historicVariables.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 79 with HistoricVariableInstance

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

the class TransientVariableTest method createVariablesUsingVariableMap.

@Test
public void createVariablesUsingVariableMap() {
    // given
    BpmnModelInstance simpleInstanceWithListener = Bpmn.createExecutableProcess("Process").startEvent().camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, ReadTransientVariableExecutionListener.class).userTask().endEvent().done();
    testRule.deploy(simpleInstanceWithListener);
    // when
    VariableMap variables = Variables.createVariables();
    variables.put(VARIABLE_NAME, Variables.untypedValue(true, true));
    runtimeService.startProcessInstanceByKey("Process", variables);
    // then
    List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list();
    List<HistoricVariableInstance> historicVariableInstances = historyService.createHistoricVariableInstanceQuery().list();
    assertEquals(0, variableInstances.size());
    assertEquals(0, historicVariableInstances.size());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) 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 80 with HistoricVariableInstance

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

the class TransientVariableTest method createTransientTypedVariablesUsingVariableMap.

@Test
public void createTransientTypedVariablesUsingVariableMap() 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().putValueTyped("a", Variables.stringValue("bar", true)).putValueTyped("b", Variables.booleanValue(true, true)).putValueTyped("c", Variables.byteArrayValue("test".getBytes(), true)).putValueTyped("d", Variables.dateValue(new Date(), true)).putValueTyped("e", Variables.doubleValue(20., true)).putValueTyped("f", Variables.integerValue(10, true)).putValueTyped("g", Variables.longValue((long) 10, true)).putValueTyped("h", Variables.shortValue((short) 10, true)).putValueTyped("i", Variables.objectValue(new Integer(100), true).create()).putValueTyped("j", Variables.untypedValue(null, true)).putValueTyped("k", Variables.untypedValue(Variables.booleanValue(true), true)).putValueTyped("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)

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