org.camunda.commons.utils.IoUtil Java Examples

The following examples show how to use org.camunda.commons.utils.IoUtil. 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: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldVerifyDmnDecisionRequirementsGraph() {
  dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DRG_EXAMPLE_DMN));  
  DmnDecisionRequirementsGraph dmnDecisionRequirementsGraph = listener.getDmnDecisionRequirementsGraph();
  Definitions definitions = listener.getDefinitions();
  assertThat(dmnDecisionRequirementsGraph.getKey())
    .isEqualTo(definitions.getId())
    .isEqualTo("dish");
  assertThat(dmnDecisionRequirementsGraph.getName())
    .isEqualTo(definitions.getName())
    .isEqualTo("Dish");
  assertThat(dmnDecisionRequirementsGraph.getDecisions().size()).isEqualTo(3);
  assertThat(dmnDecisionRequirementsGraph.getDecision("dish-decision")).isNotNull();
  assertThat(dmnDecisionRequirementsGraph.getDecision("season")).isNotNull();
  assertThat(dmnDecisionRequirementsGraph.getDecision("guestCount")).isNotNull();
}
 
Example #2
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/form/EmbeddedDeployedFormsProcess.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/form/start.form",
    "org/camunda/bpm/engine/test/api/form/task.form" })
@Test
public void testGetEmbeddedDeployedStartForm() {
  // given
  String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();

  // when
  InputStream deployedStartForm = formService.getDeployedStartForm(procDefId);

  // then
  assertNotNull(deployedStartForm);
  String fileAsString = IoUtil.fileAsString("org/camunda/bpm/engine/test/api/form/start.form");
  String deployedStartFormAsString = IoUtil.inputStreamAsString(deployedStartForm);
  assertEquals(deployedStartFormAsString, fileAsString);
}
 
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/form/DeployedFormsProcess.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/form/start.form",
    "org/camunda/bpm/engine/test/api/form/task.form" })
@Test
public void testGetDeployedStartForm() {
  // given
  String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();

  // when
  InputStream deployedStartForm = formService.getDeployedStartForm(procDefId);

  // then
  assertNotNull(deployedStartForm);
  String fileAsString = IoUtil.fileAsString("org/camunda/bpm/engine/test/api/form/start.form");
  String deployedStartFormAsString = IoUtil.inputStreamAsString(deployedStartForm);
  assertEquals(deployedStartFormAsString, fileAsString);
}
 
Example #4
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/form/DeployedFormsProcess.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/form/start.form",
    "org/camunda/bpm/engine/test/api/form/task.form" })
@Test
public void testGetDeployedTaskForm() {
  // given
  runtimeService.startProcessInstanceByKey("FormsProcess");
  String taskId = taskService.createTaskQuery().singleResult().getId();

  // when
  InputStream deployedTaskForm = formService.getDeployedTaskForm(taskId);

  // then
  assertNotNull(deployedTaskForm);
  String fileAsString = IoUtil.fileAsString("org/camunda/bpm/engine/test/api/form/task.form");
  String deployedStartFormAsString = IoUtil.inputStreamAsString(deployedTaskForm);
  assertEquals(deployedStartFormAsString, fileAsString);
}
 
Example #5
Source File: DmnTransformListenerTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldVerifyDmnDecisionRequirementsGraph() {
  dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DRG_EXAMPLE_DMN));  
  DmnDecisionRequirementsGraph dmnDecisionRequirementsGraph = listener.getDmnDecisionRequirementsGraph();
  Definitions definitions = listener.getDefinitions();
  assertThat(dmnDecisionRequirementsGraph.getKey())
    .isEqualTo(definitions.getId())
    .isEqualTo("dish");
  assertThat(dmnDecisionRequirementsGraph.getName())
    .isEqualTo(definitions.getName())
    .isEqualTo("Dish");
  assertThat(dmnDecisionRequirementsGraph.getDecisions().size()).isEqualTo(3);
  assertThat(dmnDecisionRequirementsGraph.getDecision("dish-decision")).isNotNull();
  assertThat(dmnDecisionRequirementsGraph.getDecision("season")).isNotNull();
  assertThat(dmnDecisionRequirementsGraph.getDecision("guestCount")).isNotNull();
}
 
Example #6
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/form/DeployedFormsCase.cmmn11.xml",
  "org/camunda/bpm/engine/test/api/form/task.form" })
@Test
public void testGetDeployedTaskForm_Case() {
  // given
  caseService.createCaseInstanceByKey("Case_1");
  String taskId = taskService.createTaskQuery().singleResult().getId();

  // when
  InputStream deployedTaskForm = formService.getDeployedTaskForm(taskId);

  // then
  assertNotNull(deployedTaskForm);
  String fileAsString = IoUtil.fileAsString("org/camunda/bpm/engine/test/api/form/task.form");
  String deployedStartFormAsString = IoUtil.inputStreamAsString(deployedTaskForm);
  assertEquals(deployedStartFormAsString, fileAsString);
}
 
Example #7
Source File: DmnTransformListenerTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldVerifyTransformedDmnDecision() {
  InputStream inputStream =  IoUtil.fileAsStream(DECISION_TRANSFORM_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
  dmnEngine.parseDecisionRequirementsGraph(modelInstance);
  
  DmnDecision dmnDecision = listener.getDmnDecision();
  Decision decision = listener.getDecision();

  assertThat(dmnDecision.getKey())
    .isEqualTo(decision.getId())
    .isEqualTo("decision1");
  
  assertThat(dmnDecision.getName())
    .isEqualTo(decision.getName())
    .isEqualTo("camunda");    
}
 
Example #8
Source File: FileSerializationIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGetAll() {
  // given
  Map<String, TypedValue> variables = new HashMap<>();
  variables.put(VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE);
  variables.put(ANOTHER_VARIABLE_NAME_FILE, Variables.fileValue(VARIABLE_VALUE_FILE_NAME).file(ANOTHER_VARIABLE_VALUE_FILE).create());
  engineRule.startProcessInstance(processDefinition.getId(), variables);

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

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

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

  // then
  assertThat(task.getAllVariables().size()).isEqualTo(2);
  assertThat(IoUtil.inputStreamAsString((InputStream) task.getAllVariables().get(VARIABLE_NAME_FILE)))
    .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE));
  assertThat(IoUtil.inputStreamAsString((InputStream) task.getAllVariables().get(ANOTHER_VARIABLE_NAME_FILE)))
    .isEqualTo(new String(ANOTHER_VARIABLE_VALUE_FILE));
}
 
Example #9
Source File: DmnTransformTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldParseDecisionWithRequiredDecisions() {
  InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);

  DmnDecision buyProductDecision = dmnEngine.parseDecision("buyProduct", modelInstance);
  assertDecision(buyProductDecision, "buyProduct");

  Collection<DmnDecision> buyProductrequiredDecisions = buyProductDecision.getRequiredDecisions();
  assertThat(buyProductrequiredDecisions.size()).isEqualTo(1);

  DmnDecision buyComputerDecision = getDecision(buyProductrequiredDecisions, "buyComputer");
  assertThat(buyComputerDecision).isNotNull();

  Collection<DmnDecision> buyComputerRequiredDecision = buyComputerDecision.getRequiredDecisions();
  assertThat(buyComputerRequiredDecision.size()).isEqualTo(1);

  DmnDecision buyElectronicDecision = getDecision(buyComputerRequiredDecision, "buyElectronic");
  assertThat(buyElectronicDecision).isNotNull();

  assertThat(buyElectronicDecision.getRequiredDecisions().size()).isEqualTo(0);
}
 
Example #10
Source File: DmnDecisionEvaluationListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@DecisionResource(resource = DMN_FILE)
public void shouldVerifyRootDecisionResult() {
  evaluateDecision(35, "Weekend", IoUtil.fileAsStream(DMN_FILE));

  assertThat(listener.getEvaluationEvent()).isNotNull();
  DmnDecisionTableEvaluationEvent decisionResult = (DmnDecisionTableEvaluationEvent) listener.getEvaluationEvent().getDecisionResult();
  assertThat(decisionResult).isNotNull();
  assertThat(decisionResult.getDecision().getKey()).isEqualTo("Dish");

  List<DmnEvaluatedInput> inputs = decisionResult.getInputs();
  assertThat(inputs.size()).isEqualTo(2);
  assertThat(inputs.get(0).getName()).isEqualTo("Season");
  assertThat(inputs.get(0).getValue().getValue()).isEqualTo("Summer");
  assertThat(inputs.get(1).getName()).isEqualTo("How many guests");
  assertThat(inputs.get(1).getValue().getValue()).isEqualTo(15);

  assertThat(decisionResult.getMatchingRules().size()).isEqualTo(1);
  Map<String, DmnEvaluatedOutput> outputEntries = decisionResult.getMatchingRules().get(0).getOutputEntries();
  assertThat(outputEntries.size()).isEqualTo(1);
  assertThat(outputEntries.containsKey("desiredDish")).isTrue();
  assertThat(outputEntries.get("desiredDish").getValue().getValue()).isEqualTo("Light salad");
  assertThat(decisionResult.getExecutedDecisionElements()).isEqualTo(12L);

}
 
Example #11
Source File: ParseDecisionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailIfDecisionDrgIdIsMissing() {
  try {
    InputStream inputStream = IoUtil.fileAsStream(MISSING_DECISION_REQUIREMENT_DIAGRAM_ID_DMN);
    dmnEngine.parseDecisionRequirementsGraph(inputStream);

    failBecauseExceptionWasNotThrown(DmnTransformException.class);
  }
  catch (DmnTransformException e) {
    assertThat(e)
      .hasCauseExactlyInstanceOf(DmnTransformException.class)
      .hasMessageStartingWith("DMN-02016")
      .hasMessageContaining("DMN-02017")
      .hasMessageContaining("DRD with Missing Id");
  }
}
 
Example #12
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldTransformDecisionRequirementsGraph() {
  InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
  DmnDecisionRequirementsGraph drg = dmnEngine.parseDecisionRequirementsGraph(inputStream);

  assertThat(drg).isNotNull();
  assertThat(drg.getKey()).isEqualTo("buy-decision");
  assertThat(drg.getName()).isEqualTo("Buy Decision");
  assertThat(drg.getDecisionKeys())
    .hasSize(3)
    .contains("buyProduct", "buyComputer", "buyElectronic");

  Collection<DmnDecision> decisions = drg.getDecisions();
  assertThat(decisions)
    .hasSize(3)
    .extracting("key")
    .contains("buyProduct", "buyComputer", "buyElectronic");
}
 
Example #13
Source File: DmnDecisionEvaluationListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@DecisionResource(resource = DMN_FILE)
public void shouldGetExecutedDecisionElements() {
  evaluateDecision(35, "Weekend",IoUtil.fileAsStream(DMN_FILE));

  DmnDecisionEvaluationEvent evaluationEvent = listener.getEvaluationEvent();
  assertThat(evaluationEvent).isNotNull();
  assertThat(evaluationEvent.getExecutedDecisionElements()).isEqualTo(24L);

  DmnDecisionLogicEvaluationEvent dmnDecisionTableEvaluationEvent = getDmnDecisionTable(evaluationEvent.getRequiredDecisionResults(),"Season");
  assertThat(dmnDecisionTableEvaluationEvent).isNotNull();
  assertThat(dmnDecisionTableEvaluationEvent.getExecutedDecisionElements()).isEqualTo(6L);

  dmnDecisionTableEvaluationEvent = getDmnDecisionTable(evaluationEvent.getRequiredDecisionResults(),"GuestCount");
  assertThat(dmnDecisionTableEvaluationEvent).isNotNull();
  assertThat(dmnDecisionTableEvaluationEvent.getExecutedDecisionElements()).isEqualTo(6L);

}
 
Example #14
Source File: ParseDecisionTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldFailIfDecisionDrgIdIsMissing() {
  try {
    InputStream inputStream = IoUtil.fileAsStream(MISSING_DECISION_REQUIREMENT_DIAGRAM_ID_DMN);
    dmnEngine.parseDecisionRequirementsGraph(inputStream);

    failBecauseExceptionWasNotThrown(DmnTransformException.class);
  }
  catch (DmnTransformException e) {
    assertThat(e)
      .hasCauseExactlyInstanceOf(DmnTransformException.class)
      .hasMessageStartingWith("DMN-02016")
      .hasMessageContaining("DMN-02017")
      .hasMessageContaining("DRD with Missing Id");
  }
}
 
Example #15
Source File: FileSerializationIT.java    From camunda-external-task-client-java with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGet() {
  // given
  engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE);

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

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

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

  // then
  assertThat(task.getAllVariables().size()).isEqualTo(1);
  assertThat(IoUtil.inputStreamAsString(task.getVariable(VARIABLE_NAME_FILE)))
    .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE));
}
 
Example #16
Source File: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldVerifyTransformedDmnDecision() {
  InputStream inputStream =  IoUtil.fileAsStream(DECISION_TRANSFORM_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
  dmnEngine.parseDecisionRequirementsGraph(modelInstance);
  
  DmnDecision dmnDecision = listener.getDmnDecision();
  Decision decision = listener.getDecision();

  assertThat(dmnDecision.getKey())
    .isEqualTo(decision.getId())
    .isEqualTo("decision1");
  
  assertThat(dmnDecision.getName())
    .isEqualTo(decision.getName())
    .isEqualTo("camunda");    
}
 
Example #17
Source File: TaskListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateTaskListenerOnAttachmentDelete() {
  // given
  createAndDeployModelWithTaskEventsRecorderOnUserTask(TaskListener.EVENTNAME_UPDATE);
  runtimeService.startProcessInstanceByKey("process");
  Task task = taskService.createTaskQuery().singleResult();

  Attachment attachment = taskService.createAttachment("foo", task.getId(), null, "bar", "baz", IoUtil.stringAsInputStream("foo"));

  // when
  taskService.deleteAttachment(attachment.getId());

  // then
  assertEquals(2, RecorderTaskListener.getTotalEventCount());
  assertEquals(2, RecorderTaskListener.getEventCount(TaskListener.EVENTNAME_UPDATE)); // create and delete attachment
}
 
Example #18
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldParseDecisionWithRequiredDecisions() {
  InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);

  DmnDecision buyProductDecision = dmnEngine.parseDecision("buyProduct", modelInstance);
  assertDecision(buyProductDecision, "buyProduct");

  Collection<DmnDecision> buyProductrequiredDecisions = buyProductDecision.getRequiredDecisions();
  assertThat(buyProductrequiredDecisions.size()).isEqualTo(1);

  DmnDecision buyComputerDecision = getDecision(buyProductrequiredDecisions, "buyComputer");
  assertThat(buyComputerDecision).isNotNull();

  Collection<DmnDecision> buyComputerRequiredDecision = buyComputerDecision.getRequiredDecisions();
  assertThat(buyComputerRequiredDecision.size()).isEqualTo(1);

  DmnDecision buyElectronicDecision = getDecision(buyComputerRequiredDecision, "buyElectronic");
  assertThat(buyElectronicDecision).isNotNull();

  assertThat(buyElectronicDecision.getRequiredDecisions().size()).isEqualTo(0);
}
 
Example #19
Source File: DmnDecisionEvaluationListenerTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
@DecisionResource(resource = DMN_FILE)
public void shouldVerifyRootDecisionResult() {
  evaluateDecision(35, "Weekend", IoUtil.fileAsStream(DMN_FILE));

  assertThat(listener.getEvaluationEvent()).isNotNull();
  DmnDecisionTableEvaluationEvent decisionResult = (DmnDecisionTableEvaluationEvent) listener.getEvaluationEvent().getDecisionResult();
  assertThat(decisionResult).isNotNull();
  assertThat(decisionResult.getDecision().getKey()).isEqualTo("Dish");

  List<DmnEvaluatedInput> inputs = decisionResult.getInputs();
  assertThat(inputs.size()).isEqualTo(2);
  assertThat(inputs.get(0).getName()).isEqualTo("Season");
  assertThat(inputs.get(0).getValue().getValue()).isEqualTo("Summer");
  assertThat(inputs.get(1).getName()).isEqualTo("How many guests");
  assertThat(inputs.get(1).getValue().getValue()).isEqualTo(15);

  assertThat(decisionResult.getMatchingRules().size()).isEqualTo(1);
  Map<String, DmnEvaluatedOutput> outputEntries = decisionResult.getMatchingRules().get(0).getOutputEntries();
  assertThat(outputEntries.size()).isEqualTo(1);
  assertThat(outputEntries.containsKey("desiredDish")).isTrue();
  assertThat(outputEntries.get("desiredDish").getValue().getValue()).isEqualTo("Light salad");
  assertThat(decisionResult.getExecutedDecisionElements()).isEqualTo(12L);

}
 
Example #20
Source File: DmnDecisionEvaluationListenerTest.java    From camunda-engine-dmn with Apache License 2.0 6 votes vote down vote up
@Test
@DecisionResource(resource = DMN_FILE)
public void shouldGetExecutedDecisionElements() {
  evaluateDecision(35, "Weekend",IoUtil.fileAsStream(DMN_FILE));

  DmnDecisionEvaluationEvent evaluationEvent = listener.getEvaluationEvent();
  assertThat(evaluationEvent).isNotNull();
  assertThat(evaluationEvent.getExecutedDecisionElements()).isEqualTo(24L);

  DmnDecisionLogicEvaluationEvent dmnDecisionTableEvaluationEvent = getDmnDecisionTable(evaluationEvent.getRequiredDecisionResults(),"Season");
  assertThat(dmnDecisionTableEvaluationEvent).isNotNull();
  assertThat(dmnDecisionTableEvaluationEvent.getExecutedDecisionElements()).isEqualTo(6L);

  dmnDecisionTableEvaluationEvent = getDmnDecisionTable(evaluationEvent.getRequiredDecisionResults(),"GuestCount");
  assertThat(dmnDecisionTableEvaluationEvent).isNotNull();
  assertThat(dmnDecisionTableEvaluationEvent.getExecutedDecisionElements()).isEqualTo(6L);

}
 
Example #21
Source File: FileValueTypeImplTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void fileByteArrayIsEqualToFileValueContentCase2() throws IOException {

  byte[] bytes = new byte[]{ -16, -128, -128, -128 };
  InputStream byteStream = new ByteArrayInputStream(bytes);

  String fileName = "simpleFile.txt";

  FileValue fileValue = Variables.fileValue(fileName).file(byteStream).create();
  assertThat(IoUtil.inputStreamAsByteArray(fileValue.getValue()), equalTo(bytes));
}
 
Example #22
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldParseDecisionWithMultipleRequiredDecisions() {
  InputStream inputStream = IoUtil.fileAsStream(MULTIPLE_REQUIRED_DECISIONS_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
  DmnDecision decision = dmnEngine.parseDecision("car",modelInstance);
  Collection<DmnDecision> requiredDecisions = decision.getRequiredDecisions();
  assertThat(requiredDecisions.size()).isEqualTo(2);

  DmnDecision carPriceDecision = getDecision(requiredDecisions, "carPrice");
  assertThat(carPriceDecision).isNotNull();

  DmnDecision carSpeedDecision = getDecision(requiredDecisions, "carSpeed");
  assertThat(carSpeedDecision).isNotNull();
}
 
Example #23
Source File: DmnTransformTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldParseDecisionsWithRequiredDecisions() {
  InputStream inputStream = IoUtil.fileAsStream(REQUIRED_DECISIONS_DMN);
  DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);

  List<DmnDecision> decisions = dmnEngine.parseDecisions(modelInstance);

  DmnDecision buyProductDecision = getDecision(decisions, "buyProduct");
  assertThat(buyProductDecision).isNotNull();
  Collection<DmnDecision> requiredProductDecisions = buyProductDecision.getRequiredDecisions();
  assertThat(requiredProductDecisions.size()).isEqualTo(1);

  DmnDecision requiredProductDecision = getDecision(requiredProductDecisions, "buyComputer");
  assertThat(requiredProductDecision).isNotNull();

  DmnDecision buyComputerDecision = getDecision(decisions, "buyComputer");
  assertThat(buyComputerDecision).isNotNull();
  Collection<DmnDecision> buyComputerRequiredDecisions = buyComputerDecision.getRequiredDecisions();
  assertThat(buyComputerRequiredDecisions.size()).isEqualTo(1);

  DmnDecision buyComputerRequiredDecision = getDecision(buyComputerRequiredDecisions, "buyElectronic");
  assertThat(buyComputerRequiredDecision).isNotNull();

  DmnDecision buyElectronicDecision = getDecision(decisions, "buyElectronic");
  assertThat(buyElectronicDecision).isNotNull();

  Collection<DmnDecision> buyElectronicRequiredDecisions = buyElectronicDecision.getRequiredDecisions();
  assertThat(buyElectronicRequiredDecisions.size()).isEqualTo(0);
}
 
Example #24
Source File: ByteArrayValueMapper.java    From camunda-external-task-client-java with Apache License 2.0 5 votes vote down vote up
public BytesValue convertToTypedValue(UntypedValueImpl untypedValue) {
  byte[] byteArr = null;

  Object value = untypedValue.getValue();
  if (value instanceof byte[]) {
    byteArr = (byte[]) value;
  }
  else {
    byteArr = IoUtil.inputStreamAsByteArray((InputStream) value);
  }

  return Variables.byteArrayValue(byteArr);
}
 
Example #25
Source File: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldVerifyTransformedRule() {
  dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DECISION_TRANSFORM_DMN));
  DmnDecisionTableRuleImpl dmnRule = listener.getDmnRule();
  Rule rule = listener.getRule();

  assertThat(dmnRule.getId())
    .isEqualTo(rule.getId())
    .isEqualTo("rule");
  
}
 
Example #26
Source File: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldVerifyTransformedOutput() {
  dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DECISION_TRANSFORM_DMN));
  DmnDecisionTableOutputImpl dmnOutput = listener.getDmnOutput();
  Output output = listener.getOutput();
  
  assertThat(dmnOutput.getId())
    .isEqualTo(output.getId())
    .isEqualTo("output1");
  
}
 
Example #27
Source File: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldVerifyTransformedInput() {
  dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DECISION_TRANSFORM_DMN));
  DmnDecisionTableInputImpl dmnInput = listener.getDmnInput();
  Input input = listener.getInput();
  
  assertThat(dmnInput.getId())
    .isEqualTo(input.getId())
    .isEqualTo("input1");
  
}
 
Example #28
Source File: DmnTransformListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldVerifyTransformedDmnDecisions() {
  dmnEngine.parseDecisionRequirementsGraph(IoUtil.fileAsStream(DRG_EXAMPLE_DMN));
  List<DmnDecision> transformedDecisions = listener.getTransformedDecisions();
  assertThat(transformedDecisions.size()).isEqualTo(3);
  
  assertThat(getDmnDecision(transformedDecisions, "dish-decision")).isNotNull();
  assertThat(getDmnDecision(transformedDecisions, "season")).isNotNull();
  assertThat(getDmnDecision(transformedDecisions, "guestCount")).isNotNull();

}
 
Example #29
Source File: DmnDecisionEvaluationListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
@DecisionResource(resource = DMN_FILE)
public void shouldVerifyRootDecisionResultWithNoMatchingOutput() {
  evaluateDecision(20, "Weekend", IoUtil.fileAsStream(DMN_FILE));

  assertThat(listener.getEvaluationEvent()).isNotNull();
  DmnDecisionTableEvaluationEvent decisionResult = (DmnDecisionTableEvaluationEvent) listener.getEvaluationEvent().getDecisionResult();
  assertThat(decisionResult).isNotNull();
  assertThat(decisionResult.getDecisionTable().getKey()).isEqualTo("Dish");
  assertThat(decisionResult.getMatchingRules().size()).isEqualTo(0);
  assertThat(decisionResult.getExecutedDecisionElements()).isEqualTo(12L);

}
 
Example #30
Source File: FileValueBuilderImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public FileValueBuilder file(InputStream stream) {
    try {
      return file(IoUtil.inputStreamAsByteArray(stream));
 } catch(IoUtilException e) {
 	throw new IllegalArgumentException(e);
 }
}