use of org.camunda.bpm.dmn.engine.DmnEngineException in project camunda-engine-dmn by camunda.
the class DmnEngineApiTest method shouldFailEvaluatingDecisionIfDecisionLogicIsNotSupported.
@Test
public void shouldFailEvaluatingDecisionIfDecisionLogicIsNotSupported() {
DmnDecisionImpl decision = new DmnDecisionImpl();
decision.setKey("decision");
decision.setDecisionLogic(mock(DmnDecisionLogic.class));
try {
dmnEngine.evaluateDecision(decision, variables);
failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (DmnEngineException e) {
assertThat(e).hasMessageStartingWith("DMN-01012");
}
}
use of org.camunda.bpm.dmn.engine.DmnEngineException in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecision_DmnEngineException.
@Test
public void testEvaluateDecision_DmnEngineException() {
String message = "expected message";
when(decisionEvaluationBuilderMock.evaluate()).thenThrow(new DmnEngineException(message));
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.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", is(RestException.class.getSimpleName())).body("message", containsString(message)).when().post(EVALUATE_DECISION_URL);
}
use of org.camunda.bpm.dmn.engine.DmnEngineException in project camunda-bpm-platform by camunda.
the class DecisionDefinitionResourceImpl method evaluateDecision.
@Override
public List<Map<String, VariableValueDto>> evaluateDecision(UriInfo context, EvaluateDecisionDto parameters) {
DecisionService decisionService = engine.getDecisionService();
Map<String, Object> variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
try {
DmnDecisionResult decisionResult = decisionService.evaluateDecisionById(decisionDefinitionId).variables(variables).evaluate();
return createDecisionResultDto(decisionResult);
} catch (AuthorizationException e) {
throw e;
} catch (NotFoundException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.NOT_FOUND, e, errorMessage);
} catch (NotValidException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new InvalidRequestException(Status.BAD_REQUEST, e, errorMessage);
} catch (ProcessEngineException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
} catch (DmnEngineException e) {
String errorMessage = String.format("Cannot evaluate decision %s: %s", decisionDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
}
}
use of org.camunda.bpm.dmn.engine.DmnEngineException in project camunda-bpm-platform by camunda.
the class DecisionDefinitionRestServiceInteractionTest method testEvaluateDecisionByKey_DmnEngineException.
@Test
public void testEvaluateDecisionByKey_DmnEngineException() {
String message = "expected message";
when(decisionEvaluationBuilderMock.evaluate()).thenThrow(new DmnEngineException(message));
Map<String, Object> json = new HashMap<String, Object>();
json.put("variables", Collections.emptyMap());
given().pathParam("key", MockProvider.EXAMPLE_DECISION_DEFINITION_KEY).contentType(POST_JSON_CONTENT_TYPE).body(json).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()).contentType(ContentType.JSON).body("type", is(RestException.class.getSimpleName())).body("message", containsString(message)).when().post(EVALUATE_DECISION_BY_KEY_URL);
}
Aggregations