org.camunda.bpm.engine.variable.Variables Java Examples

The following examples show how to use org.camunda.bpm.engine.variable.Variables. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrimitiveVariableIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shoudGetVariableTyped_NullShort() {
  // given
  engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME, Variables.shortValue(null));

  // when
  client.subscribe(EXTERNAL_TASK_TOPIC_FOO)
    .handler(handler)
    .open();

  // then
  clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty());

  ExternalTask task = handler.getHandledTasks().get(0);

  TypedValue typedValue = task.getVariableTyped(VARIABLE_NAME);
  assertThat(typedValue.getValue()).isNull();
  assertThat(typedValue.getType()).isEqualTo(SHORT);
}
 
Example #2
Source File: BoundaryErrorEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment( resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/BoundaryErrorEventTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownByExecuteOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  variables.putAll(throwException());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskException", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example #3
Source File: FormServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
@Test
public void testSubmitTaskFormForCmmnHumanTask() {
  caseService.createCaseInstanceByKey("oneTaskCase");

  Task task = taskService.createTaskQuery().singleResult();

  String stringValue = "some string";
  String serializedValue = "some value";

  formService.submitTaskForm(task.getId(), createVariables()
      .putValueTyped("boolean", booleanValue(null))
      .putValueTyped("string", stringValue(stringValue))
      .putValueTyped("serializedObject", serializedObjectValue(serializedValue)
          .objectTypeName(String.class.getName())
          .serializationDataFormat(Variables.SerializationDataFormats.JAVA)
          .create())
      .putValueTyped("object", objectValue(serializedValue).create()));
}
 
Example #4
Source File: JsonSerializationIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailWhileDeserialization() {
  // given
  ObjectValue objectValue = Variables.serializedObjectValue(VARIABLE_VALUE_JSON_SERIALIZED)
    .objectTypeName(FailingDeserializationBean.class.getName())
    .serializationDataFormat(JSON_DATAFORMAT_NAME)
    .create();

  engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME_JSON, objectValue);

  // then
  thrown.expect(ValueMapperException.class);

  // when
  client.subscribe(EXTERNAL_TASK_TOPIC_FOO)
    .handler(handler)
    .open();

  clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty());

  ExternalTask task = handler.getHandledTasks().get(0);
  task.getVariable(VARIABLE_NAME_JSON);
}
 
Example #5
Source File: ExternalTaskQueryByPriorityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityLowerThanOrEquals() {
  // given five jobs with priorities from 1 to 5
  //each process has two external tasks - one with priority expression and one without priority
  List<ProcessInstance> instances = new ArrayList<ProcessInstance>();

  for (int i = 0; i < 5; i++) {
    instances.add(runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess",
        Variables.createVariables().putValue("priority", i)));
  }

  // when making a external task query and filtering by priority
  // then the correct external tasks are returned
  List<ExternalTask> tasks = externalTaskService.createExternalTaskQuery().priorityLowerThanOrEquals(2).list();
  assertEquals(8, tasks.size());

  for (ExternalTask task : tasks) {
    assertTrue(task.getPriority() <= 2);
  }
}
 
Example #6
Source File: ExternalTaskQueryByPriorityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/externalTaskPriorityExpression.bpmn20.xml")
public void testFilterByExternalTaskPriorityLowerAndHigher() {
  // given five jobs with priorities from 1 to 5
  List<ProcessInstance> instances = new ArrayList<ProcessInstance>();

  for (int i = 0; i < 5; i++) {
    instances.add(runtimeService.startProcessInstanceByKey("twoExternalTaskWithPriorityProcess",
        Variables.createVariables().putValue("priority", i)));
  }

  // when making a external task query and filtering by external task priority
  // then the correct external task is returned
  ExternalTask task = externalTaskService.createExternalTaskQuery()
                                         .priorityHigherThanOrEquals(2L)
                                         .priorityLowerThanOrEquals(2L)
                                         .singleResult();
  assertNotNull(task);
  assertEquals(2, task.getPriority());
  assertEquals(instances.get(2).getId(), task.getProcessInstanceId());
}
 
Example #7
Source File: ProcessInstanceModificationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testStartBeforeWithVariables() {
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway");

  runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task2").setVariable("procInstVar", "procInstValue")
      .setVariableLocal("localVar", "localValue").setVariables(Variables.createVariables().putValue("procInstMapVar", "procInstMapValue"))
      .setVariablesLocal(Variables.createVariables().putValue("localMapVar", "localMapValue")).execute();

  ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.getId());
  assertNotNull(updatedTree);
  assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task1").activity("task2").done());

  ActivityInstance task2Instance = getChildInstanceForActivity(updatedTree, "task2");
  assertNotNull(task2Instance);
  assertEquals(1, task2Instance.getExecutionIds().length);
  String task2ExecutionId = task2Instance.getExecutionIds()[0];

  assertEquals(4, runtimeService.createVariableInstanceQuery().count());
  assertEquals("procInstValue", runtimeService.getVariableLocal(processInstance.getId(), "procInstVar"));
  assertEquals("localValue", runtimeService.getVariableLocal(task2ExecutionId, "localVar"));
  assertEquals("procInstMapValue", runtimeService.getVariableLocal(processInstance.getId(), "procInstMapVar"));
  assertEquals("localMapValue", runtimeService.getVariableLocal(task2ExecutionId, "localMapVar"));

  completeTasksInOrder("task1", "task2");
  assertProcessEnded(processInstance.getId());
}
 
Example #8
Source File: DmnDecisionTableResultTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@DecisionResource(resource = RESULT_TEST_DMN)
public void testSingleOutputUntypedValue() {
  DmnDecisionTableResult decisionResult = evaluateWithMatchingRules(SINGLE_OUTPUT_VALUE);
  assertThat(decisionResult).hasSize(1);

  DmnDecisionRuleResult ruleResult = decisionResult.getFirstResult();

  TypedValue typedEntry = ruleResult.getEntryTyped("firstOutput");
  assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));

  typedEntry = ruleResult.getEntryTyped("secondOutput");
  assertThat(typedEntry).isNull();

  typedEntry = ruleResult.getFirstEntryTyped();
  assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));

  typedEntry = ruleResult.getSingleEntryTyped();
  assertThat(typedEntry).isEqualTo(Variables.untypedValue("singleValue"));
}
 
Example #9
Source File: SendMailConnectorProcessTest.java    From camunda-bpm-mail with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = "processes/mail-send-file.bpmn")
public void sendMailWithFileName() throws Exception {
  File attachment = new File(getClass().getResource("/attachment.txt").toURI());
  assertThat(attachment.exists()).isTrue();

  engineRule.getRuntimeService().startProcessInstanceByKey("send-mail",
      Variables.createVariables().putValue("file", attachment.getPath()));

  MimeMessage[] mails = greenMail.getReceivedMessages();
  assertThat(mails).hasSize(1);

  MimeMessage mail = mails[0];

  assertThat(mail.getContent()).isInstanceOf(MimeMultipart.class);
  MimeMultipart multiPart = (MimeMultipart) mail.getContent();

  assertThat(multiPart.getCount()).isEqualTo(1);
  assertThat(GreenMailUtil.getBody(multiPart.getBodyPart(0))).isEqualTo("plain text");
}
 
Example #10
Source File: IntermediateConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/conditional/IntermediateConditionalEventTest.testSubProcessVariableValue.bpmn20.xml"})
public void testSubProcessVariableSetValueOnParent() {
  //given process with intermediate conditional event and variable with wrong value
  Map<String, Object> variables = Variables.createVariables();
  variables.put(VARIABLE_NAME, 0);
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY, variables);

  //when variable is set to correct value
  runtimeService.setVariable(procInst.getId(), VARIABLE_NAME, 1);

  //then process instance is ended, since condition was true
  procInst = runtimeService.createProcessInstanceQuery()
                           .processDefinitionKey(CONDITIONAL_EVENT_PROCESS_KEY)
                           .singleResult();
  assertNull(procInst);
}
 
Example #11
Source File: CaseInstanceFakeTest.java    From camunda-bpm-mockito with Apache License 2.0 6 votes vote down vote up
@Test
public void prepare_with_service_mock() {
  CaseService caseService = mock(CaseService.class);
  String uuid = UUID.randomUUID().toString();
  String businessKey = "12";

  AtomicReference<CaseInstanceFake> reference = CaseInstanceFake.prepareMock(caseService, uuid);

  assertThat(reference.get()).isNull();

  CaseInstance instance = caseService.createCaseInstanceByKey("case", businessKey, Variables.putValue("foo", "bar"));
  assertThat(reference.get()).isNotNull();
  assertThat(instance.getCaseInstanceId()).isEqualTo(uuid);

  assertThat(caseService.getVariable(uuid, "foo")).isEqualTo("bar");

  caseService.setVariable(uuid, "hello", 456);
  assertThat(caseService.getVariable(uuid, "hello")).isEqualTo(456);

  assertThat(caseService.createCaseInstanceQuery().singleResult()).isEqualTo(reference.get());
}
 
Example #12
Source File: ErrorEventSubProcessTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/ErrorEventSubProcessTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchErrorThrownBySignalOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult();
  assertNotNull(serviceTask);

  runtimeService.setVariables(pi, throwError());
  runtimeService.signal(serviceTask.getId());

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertTrue((Boolean) runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskError", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example #13
Source File: PrimitiveVariableIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shoudGetVariable_Bytes() {
  // given
  engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME, Variables.byteArrayValue(VARIABLE_VALUE_BYTES));

  // when
  client.subscribe(EXTERNAL_TASK_TOPIC_FOO)
    .handler(handler)
    .open();

  // then
  clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty());

  ExternalTask task = handler.getHandledTasks().get(0);

  byte[] variableValue = task.getVariable(VARIABLE_NAME);
  assertThat(variableValue).isEqualTo(VARIABLE_VALUE_BYTES);
}
 
Example #14
Source File: PaSerializationIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSelectSequenceFlowAndCompleteProcessInstance_JavaSerialization() {
  // given
  ObjectValue objectValueJavaSerialization = Variables
    .objectValue(VARIABLE_VALUE_BEAN_FOO)
    .serializationDataFormat(JAVA_DATAFORMAT_NAME)
    .create();

  client.subscribe(EXTERNAL_TASK_TOPIC_NAME)
    .handler(invocationHandler)
    .open();

  clientRule.waitForFetchAndLockUntil(() -> !invocationHandler.getInvocations().isEmpty());

  RecordedInvocation invocation = invocationHandler.getInvocations().get(0);
  ExternalTaskService service = invocation.getExternalTaskService();
  ExternalTask task = invocation.getExternalTask();

  // when
  service.complete(task, Collections.singletonMap(VARIABLE_NAME, objectValueJavaSerialization));

  // then
  HistoricProcessInstanceDto processInstanceDto = engineRule.getHistoricProcessInstanceById(processInstance.getId());
  assertThat(processInstanceDto.getEndTime()).isNotNull();
}
 
Example #15
Source File: CaseExecutionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetFileVariable() {
  String variableKey = "aVariableKey";
  final byte[] byteContent = "some bytes".getBytes();
  String filename = "test.txt";
  String mimeType = "text/plain";
  FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(mimeType).create();

  when(caseServiceMock.getVariableTyped(MockProvider.EXAMPLE_CASE_INSTANCE_ID, variableKey, true))
  .thenReturn(variableValue);

  given()
    .pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID)
    .pathParam("varId", variableKey)
  .then().expect()
    .statusCode(Status.OK.getStatusCode())
    .contentType(ContentType.JSON.toString())
  .and()
    .body("valueInfo.mimeType", equalTo(mimeType))
    .body("valueInfo.filename", equalTo(filename))
    .body("value", nullValue())
  .when().get(SINGLE_CASE_EXECUTION_VARIABLE_URL);
}
 
Example #16
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public ShortValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }

  ShortValueImpl shortValue = null;
  NumberValue numberValue = (NumberValue) typedValue;
  if (numberValue.getValue() != null) {
    shortValue = (ShortValueImpl) Variables.shortValue(numberValue.getValue().shortValue());
  } else {
    shortValue =  (ShortValueImpl) Variables.shortValue(null);
  }
  shortValue.setTransient(numberValue.isTransient());
  return shortValue;
}
 
Example #17
Source File: FilterTaskQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * See CAM-9613
 */
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"})
public void FAILING_testByteArrayVariable() {
  // given
  runtimeService.startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValue("bytesVariable", "aByteArray".getBytes()));

  TaskQuery query = taskService.createTaskQuery()
    .processVariableValueEquals("bytesVariable", "aByteArray".getBytes());

  Filter filter = filterService.newTaskFilter("filter");
  filter.setQuery(query);

  // when
  filterService.saveFilter(filter);

  // then
  assertThat(filterService.count(filter.getId()), is(1L));
}
 
Example #18
Source File: RemovalTimeStrategyStartTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources = {
  "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml"
})
public void shouldNotResolveHistoricDecisionInputInstance() {
  // given

  // when
  decisionService.evaluateDecisionTableByKey("dish-decision", Variables.createVariables()
    .putValue("temperature", 32)
    .putValue("dayType", "Weekend"));

  HistoricDecisionInstance historicDecisionInstance = historyService.createHistoricDecisionInstanceQuery()
    .rootDecisionInstancesOnly()
    .includeInputs()
    .singleResult();

  // assume
  assertThat(historicDecisionInstance, notNullValue());

  List<HistoricDecisionInputInstance> historicDecisionInputInstances = historicDecisionInstance.getInputs();

  // then
  assertThat(historicDecisionInputInstances.get(0).getRemovalTime(), nullValue());
  assertThat(historicDecisionInputInstances.get(1).getRemovalTime(), nullValue());
}
 
Example #19
Source File: PrimitiveVariableIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shoudGetVariable_Double() {
  // given
  engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME, Variables.doubleValue(VARIABLE_VALUE_DOUBLE));

  // when
  client.subscribe(EXTERNAL_TASK_TOPIC_FOO)
    .handler(handler)
    .open();

  // then
  clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty());

  ExternalTask task = handler.getHandledTasks().get(0);

  double variableValue = task.getVariable(VARIABLE_NAME);
  assertThat(variableValue).isEqualTo(VARIABLE_VALUE_DOUBLE);
}
 
Example #20
Source File: JavaSerializationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStandaloneTaskVariable() {
  Task task = taskService.newTask();
  task.setName("gonzoTask");
  taskService.saveTask(task);

  String taskId = task.getId();

  try {
    taskService
      .setVariable(taskId, "instrument", Variables.serializedObjectValue("trumpet").serializationDataFormat(Variables.SerializationDataFormats.JAVA).create());
    fail("Exception is expected.");
  } catch (ProcessEngineException ex) {
    assertEquals("ENGINE-17007 Cannot set variable with name instrument. Java serialization format is prohibited", ex.getMessage());
  } finally {
    taskService.deleteTask(taskId, true);
  }

}
 
Example #21
Source File: TaskServiceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources={"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"})
@Test
public void testHumanTaskCompleteWithVariables() {
  // given
  caseService.createCaseInstanceByKey("oneTaskCase");

  String humanTaskId = caseService
      .createCaseExecutionQuery()
      .activityId("PI_HumanTask_1")
      .singleResult()
      .getId();

  String taskId = taskService.createTaskQuery().singleResult().getId();

  String variableName = "aVariable";
  String variableValue = "aValue";

  // when
  taskService.complete(taskId, Variables.createVariables().putValue(variableName, variableValue));

  // then
  VariableInstance variable = runtimeService.createVariableInstanceQuery().singleResult();

  assertEquals(variable.getName(), variableName);
  assertEquals(variable.getValue(), variableValue);
}
 
Example #22
Source File: HistoricDecisionInstanceStatisticsQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatisticForRootDecisionWithFakeInstanceConstraintEvaluation() throws Exception {
  //when
  decisionService.evaluateDecisionTableByKey(DISH_DECISION)
      .variables(Variables.createVariables().putValue(TEMPERATURE, 21).putValue(DAY_TYPE, WEEKEND))
      .evaluate();

  DecisionRequirementsDefinition decisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery().singleResult();

  HistoricDecisionInstanceStatisticsQuery query = historyService
      .createHistoricDecisionInstanceStatisticsQuery(
          decisionRequirementsDefinition.getId())
      .decisionInstanceId(NON_EXISTING);

  //then
  assertThat(query.count(), is(0L));
  assertThat(query.list().size(), is(0));


}
 
Example #23
Source File: ErrorEventSubProcessTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/bpmn/event/error/ErrorEventSubProcessTest.testCatchErrorThrownByDelegateExpression.bpmn20.xml"
})
public void testCatchExceptionThrownBySignalOfDelegateExpression() {
  VariableMap variables = Variables.createVariables().putValue("myDelegate", new ThrowErrorDelegate());
  String pi = runtimeService.startProcessInstanceByKey("testProcess", variables).getId();

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertNull(runtimeService.getVariable(pi, "signaled"));

  Execution serviceTask = runtimeService.createExecutionQuery().processInstanceId(pi).activityId("serviceTask").singleResult();
  assertNotNull(serviceTask);

  runtimeService.setVariables(pi, throwException());
  runtimeService.signal(serviceTask.getId());

  assertTrue((Boolean) runtimeService.getVariable(pi, "executed"));
  assertTrue((Boolean) runtimeService.getVariable(pi, "signaled"));

  Task userTask = taskService.createTaskQuery().processInstanceId(pi).singleResult();
  assertNotNull(userTask);
  assertEquals("userTaskException", userTask.getTaskDefinitionKey());

  taskService.complete(userTask.getId());
}
 
Example #24
Source File: DmnDecisionTaskTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/decisiontask/DmnDecisionTaskTest.testCallDecisionByVersionAsExpressionStartsWithDollar.cmmn",
    DECISION_OKAY_DMN
  })
public void testCallDecisionByVersionAsExpressionStartsWithDollar() {
  // given
  String deploymentId = repositoryService.createDeployment()
      .addClasspathResource(DECISION_NOT_OKAY_DMN)
      .deploy()
      .getId();

  CaseInstance caseInstance = createCaseInstanceByKey(CASE_KEY, Variables.createVariables().putValue("myVersion", 2));

  // then
  assertNull(queryCaseExecutionByActivityId(DECISION_TASK));
  assertEquals("not okay", getDecisionResult(caseInstance));

  repositoryService.deleteDeployment(deploymentId, true);
}
 
Example #25
Source File: EventSubProcessStartConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment(resources ={ "org/camunda/bpm/engine/test/bpmn/event/conditional/EventSubProcessStartConditionalEventTest.testVariableCondition.bpmn20.xml"})
public void testVariableConditionAndStartingWithVar() {
  //given process with event sub process conditional start event
  Map<String, Object> vars = Variables.createVariables();
  vars.put(VARIABLE_NAME, 1);

  //when starting process with variable
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY, vars);

  //then event sub process is triggered via default evaluation behavior
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
  assertEquals(0, conditionEventSubscriptionQuery.list().size());
}
 
Example #26
Source File: DmnDataTypeTransformerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void booleanType() {
  DmnDataTypeTransformer typeTransformer = registry.getTransformer("boolean");

  assertThat(typeTransformer.transform(true), is((TypedValue) Variables.booleanValue(true)));
  assertThat(typeTransformer.transform(false), is((TypedValue) Variables.booleanValue(false)));

  assertThat(typeTransformer.transform("true"), is((TypedValue) Variables.booleanValue(true)));
  assertThat(typeTransformer.transform("false"), is((TypedValue) Variables.booleanValue(false)));
}
 
Example #27
Source File: FeelIntegrationTest.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
@Test
@DecisionResource(resource = DMN)
public void testFeelInputEntryWithAlternativeName() {
  DefaultDmnEngineConfiguration configuration = (DefaultDmnEngineConfiguration) getDmnEngineConfiguration();
  configuration.setDefaultInputEntryExpressionLanguage("feel");
  DmnEngine dmnEngine = configuration.buildEngine();

  DmnDecisionResult decisionResult = dmnEngine.evaluateDecision(decision, Variables.createVariables().putValue("score", 3));

  assertThat(decisionResult.getSingleEntry()).isEqualTo("a");

  verify(feelEngineSpy, atLeastOnce()).evaluateSimpleUnaryTests(anyString(), anyString(), any(VariableContext.class));
}
 
Example #28
Source File: VariableValueDto.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected FileValue fileValueWithDecodedString(FileValue fileValue, String value) {
  return Variables.fileValue(fileValue.getFilename())
                  .file(Base64.decodeBase64(value))
                  .mimeType(fileValue.getMimeType())
                  .encoding(fileValue.getEncoding())
                  .create();
}
 
Example #29
Source File: DmnBusinessRuleTaskResultMappingTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { SINGLE_ENTRY_BPMN, TEST_DECISION})
public void testSingleEntryMapping() {
  ProcessInstance processInstance = startTestProcess("single entry");

  assertEquals("foo", runtimeService.getVariable(processInstance.getId(), "result"));
  assertEquals(Variables.stringValue("foo"), runtimeService.getVariableTyped(processInstance.getId(), "result"));
}
 
Example #30
Source File: DmnDataTypeTransformerTest.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
@Test
public void doubleType() {
  DmnDataTypeTransformer typeTransformer = registry.getTransformer("double");

  assertThat(typeTransformer.transform(4.2), is((TypedValue) Variables.doubleValue(4.2)));
  assertThat(typeTransformer.transform("4.2"), is((TypedValue) Variables.doubleValue(4.2)));
  assertThat(typeTransformer.transform(4), is((TypedValue) Variables.doubleValue(4.0)));
  assertThat(typeTransformer.transform(4L), is((TypedValue) Variables.doubleValue(4.0)));

  assertThat(typeTransformer.transform(Double.MIN_VALUE), is((TypedValue) Variables.doubleValue(Double.MIN_VALUE)));
  assertThat(typeTransformer.transform(Double.MAX_VALUE), is((TypedValue) Variables.doubleValue(Double.MAX_VALUE)));
  assertThat(typeTransformer.transform(-Double.MAX_VALUE), is((TypedValue) Variables.doubleValue(-Double.MAX_VALUE)));
  assertThat(typeTransformer.transform(Long.MAX_VALUE), is((TypedValue) Variables.doubleValue((double) Long.MAX_VALUE)));
}