Java Code Examples for org.camunda.bpm.engine.variable.Variables#booleanValue()

The following examples show how to use org.camunda.bpm.engine.variable.Variables#booleanValue() . 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: BooleanFormType.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public TypedValue convertValue(TypedValue propertyValue) {
  if(propertyValue instanceof BooleanValue) {
    return propertyValue;
  }
  else {
    Object value = propertyValue.getValue();
    if(value == null) {
      return Variables.booleanValue(null, propertyValue.isTransient());
    }
    else if((value instanceof Boolean) || (value instanceof String)) {
      return Variables.booleanValue(new Boolean(value.toString()), propertyValue.isTransient());
    }
    else {
      throw new ProcessEngineException("Value '"+value+"' is not of type Boolean.");
    }
  }
}
 
Example 2
Source File: CaseExecutionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCannotDownloadVariableOtherThanFile() {
  String variableKey = "aVariableKey";
  BooleanValue variableValue = Variables.booleanValue(true);

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

  given()
    .pathParam("id", MockProvider.EXAMPLE_CASE_INSTANCE_ID)
    .pathParam("varId", variableKey)
  .then().expect()
    .statusCode(Status.BAD_REQUEST.getStatusCode())
    .contentType(MediaType.APPLICATION_JSON)
  .when().get(SINGLE_CASE_EXECUTION_LOCAL_BINARY_VARIABLE_URL);
}
 
Example 3
Source File: BooleanValueSerializer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public BooleanValue readValue(ValueFields valueFields, boolean asTransientValue) {
  Boolean boolValue = null;
  Long longValue = valueFields.getLongValue();

  if(longValue != null) {
    boolValue = longValue.equals(TRUE);
  }

  return Variables.booleanValue(boolValue, asTransientValue);
}
 
Example 4
Source File: TaskVariableLocalRestResourceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCannotDownloadVariableOtherThanFile() {
  String variableKey = "aVariableKey";
  BooleanValue variableValue = Variables.booleanValue(true);

  when(taskServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);

  given()
    .pathParam("id", EXAMPLE_TASK_ID)
    .pathParam("varId", variableKey)
  .then().expect()
    .statusCode(Status.BAD_REQUEST.getStatusCode())
  .when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
}
 
Example 5
Source File: TaskVariableRestResourceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCannotDownloadVariableOtherThanFile() {
  String variableKey = "aVariableKey";
  BooleanValue variableValue = Variables.booleanValue(true);

  when(taskServiceMock.getVariableTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);

  given()
    .pathParam("id", EXAMPLE_TASK_ID)
    .pathParam("varId", variableKey)
  .then().expect()
    .statusCode(Status.BAD_REQUEST.getStatusCode())
  .when().get(SINGLE_TASK_SINGLE_BINARY_VARIABLE_URL);
}
 
Example 6
Source File: ExecutionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCannotDownloadVariableOtherThanFile() {
  String variableKey = "aVariableKey";
  BooleanValue variableValue = Variables.booleanValue(true);

  when(runtimeServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);

  given()
    .pathParam("id", EXAMPLE_TASK_ID)
    .pathParam("varId", variableKey)
  .then().expect()
    .statusCode(Status.BAD_REQUEST.getStatusCode())
  .when().get(SINGLE_EXECUTION_LOCAL_BINARY_VARIABLE_URL);
}
 
Example 7
Source File: CaseInstanceRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCannotDownloadVariableOtherThanFile() {
  String variableKey = "aVariableKey";
  BooleanValue variableValue = Variables.booleanValue(true);

  when(caseServiceMock.getVariableLocalTyped(eq(EXAMPLE_TASK_ID), eq(variableKey), anyBoolean())).thenReturn(variableValue);

  given()
    .pathParam("id", EXAMPLE_TASK_ID)
    .pathParam("varId", variableKey)
  .then().expect()
    .statusCode(Status.BAD_REQUEST.getStatusCode())
  .when().get(SINGLE_CASE_INSTANCE_BINARY_VARIABLE_URL);
}
 
Example 8
Source File: BooleanValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 4 votes vote down vote up
public BooleanValue convertToTypedValue(UntypedValueImpl untypedValue) {
  return Variables.booleanValue((Boolean) untypedValue.getValue());
}
 
Example 9
Source File: BooleanValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 4 votes vote down vote up
public BooleanValue readValue(TypedValueField typedValueField) {
  Boolean boolValue = (Boolean) typedValueField.getValue();
  return Variables.booleanValue(boolValue);
}
 
Example 10
Source File: BooleanValueSerializer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public BooleanValue convertToTypedValue(UntypedValueImpl untypedValue) {
  return Variables.booleanValue((Boolean) untypedValue.getValue(), untypedValue.isTransient());
}
 
Example 11
Source File: ProcessTaskTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testVariablesRoundtrip.cmmn",
    "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"
  })
public void testInputOutputLimitedTypedVariables() {
  String variableName = "aVariable";
  String variableName2 = "anotherVariable";
  TypedValue caseVariableValue = Variables.stringValue("abc");
  TypedValue caseVariableValue2 = Variables.integerValue(null);

  String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE,
      Variables.createVariables().putValue(variableName, caseVariableValue)
      .putValue(variableName2, caseVariableValue2)).getId();

  String processInstanceId = queryProcessInstance().getId();
  TypedValue value = runtimeService.getVariableTyped(processInstanceId, variableName);
  assertThat(value, is(caseVariableValue));
  value = runtimeService.getVariableTyped(processInstanceId, variableName2);
  assertThat(value, is(caseVariableValue2));


  TypedValue processVariableValue = Variables.stringValue("cba");
  TypedValue processVariableValue2 = Variables.booleanValue(null);
  runtimeService.setVariable(processInstanceId, variableName, processVariableValue);
  runtimeService.setVariable(processInstanceId, variableName2, processVariableValue2);

  // should also complete process instance
  taskService.complete(queryTask().getId());

  value = caseService.getVariableTyped(caseInstanceId, variableName);
  assertThat(value, is(processVariableValue));
  value = caseService.getVariableTyped(caseInstanceId, variableName2);
  assertThat(value, is(processVariableValue2));
  // complete ////////////////////////////////////////////////////////

  assertProcessEnded(processInstanceId);

  close(caseInstanceId);
  assertCaseEnded(caseInstanceId);

}
 
Example 12
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public BooleanValue createValue(Object value, Map<String, Object> valueInfo) {
  return Variables.booleanValue((Boolean) value, isTransient(valueInfo));
}