use of org.camunda.bpm.dmn.engine.DmnDecisionResult in project camunda-bpm-platform by camunda.
the class DecisionEvaluationUtil method evaluateDecision.
public static void evaluateDecision(AbstractVariableScope execution, BaseCallableElement callableElement, String resultVariable, DecisionResultMapper decisionResultMapper) throws Exception {
DecisionDefinition decisionDefinition = resolveDecisionDefinition(callableElement, execution);
DecisionInvocation invocation = createInvocation(decisionDefinition, execution);
invoke(invocation);
DmnDecisionResult result = invocation.getInvocationResult();
if (result != null) {
execution.setVariableLocalTransient(DECISION_RESULT_VARIABLE, result);
if (resultVariable != null && decisionResultMapper != null) {
Object mappedDecisionResult = decisionResultMapper.mapDecisionResult(result);
execution.setVariable(resultVariable, mappedDecisionResult);
}
}
}
use of org.camunda.bpm.dmn.engine.DmnDecisionResult in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionMultipleDecisionOutputs.
@Test
public void testEvaluateDecisionMultipleDecisionOutputs() {
DmnDecisionResult decisionResult = new MockDecisionResultBuilder().resultEntries().entry("status", Variables.stringValue("gold")).resultEntries().entry("assignee", Variables.stringValue("manager")).build();
when(decisionEvaluationBuilderMock.evaluate()).thenReturn(decisionResult);
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", Collections.emptyMap());
given().pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.OK.getStatusCode()).body("size()", is(2)).body("[0].size()", is(1)).body("[0].status.value", is("gold")).body("[1].size()", is(1)).body("[1].assignee.value", is("manager")).when().post(EVALUATE_DECISION_URL);
}
use of org.camunda.bpm.dmn.engine.DmnDecisionResult in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionByKey.
@Test
public void testEvaluateDecisionByKey() {
DmnDecisionResult decisionResult = MockProvider.createMockDecisionResult();
when(decisionEvaluationBuilderMock.evaluate()).thenReturn(decisionResult);
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", VariablesBuilder.create().variable("amount", 420).variable("invoiceCategory", "MISC").getVariables());
given().pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EVALUATE_DECISION_BY_KEY_URL);
Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("amount", 420);
expectedVariables.put("invoiceCategory", "MISC");
verify(decisionEvaluationBuilderMock).variables(expectedVariables);
verify(decisionEvaluationBuilderMock).evaluate();
}
use of org.camunda.bpm.dmn.engine.DmnDecisionResult in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionByKeyAndTenantId.
@Test
public void testEvaluateDecisionByKeyAndTenantId() {
DecisionDefinition mockDefinition = MockProvider.mockDecisionDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
setUpRuntimeData(mockDefinition);
DmnDecisionResult decisionResult = MockProvider.createMockDecisionResult();
when(decisionEvaluationBuilderMock.evaluate()).thenReturn(decisionResult);
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", VariablesBuilder.create().variable("amount", 420).variable("invoiceCategory", "MISC").getVariables());
given().pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.OK.getStatusCode()).when().post(EVALUATE_DECISION_BY_KEY_AND_TENANT_ID_URL);
Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("amount", 420);
expectedVariables.put("invoiceCategory", "MISC");
verify(decisionDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(decisionEvaluationBuilderMock).variables(expectedVariables);
verify(decisionEvaluationBuilderMock).evaluate();
}
use of org.camunda.bpm.dmn.engine.DmnDecisionResult in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionSingleDecisionOutput.
@Test
public void testEvaluateDecisionSingleDecisionOutput() {
DmnDecisionResult decisionResult = new MockDecisionResultBuilder().resultEntries().entry("status", Variables.stringValue("gold")).build();
when(decisionEvaluationBuilderMock.evaluate()).thenReturn(decisionResult);
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", Collections.emptyMap());
given().pathParam("id", MockProvider.EXAMPLE_DECISION_DEFINITION_ID).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.OK.getStatusCode()).body("size()", is(1)).body("[0].size()", is(1)).body("[0].status", is(notNullValue())).body("[0].status.value", is("gold")).when().post(EVALUATE_DECISION_URL);
}
Aggregations