@Test
public void getEvaluatedCaseValueException() {

    //Given
    //Task Definition
    TaskDef taskDef = new TaskDef();
    Map<String, Object> inputMap = new HashMap<>();
    inputMap.put("Id", "${workflow.input.Id}");
    List<Map<String, Object>> taskDefinitionInput = new LinkedList<>();
    taskDefinitionInput.add(inputMap);
    //Decision task instance
    WorkflowTask decisionTask = new WorkflowTask();
    decisionTask.setType(TaskType.DECISION.name());
    decisionTask.setName("Decision");
    decisionTask.setTaskReferenceName("decisionTask");
    decisionTask.setDefaultCase(Collections.singletonList(task1));
    decisionTask.setCaseValueParam("case");
    decisionTask.getInputParameters().put("Id", "${workflow.input.Id}");
    decisionTask.setCaseExpression("if ($Id == null) 'bad input'; else if ( ($Id != null && $Id % 2 == 0)) 'even'; else 'odd'; ");
    Map<String, List<WorkflowTask>> decisionCases = new HashMap<>();
    decisionCases.put("even", Collections.singletonList(task2));
    decisionCases.put("odd", Collections.singletonList(task3));
    decisionTask.setDecisionCases(decisionCases);
    //Workflow instance
    WorkflowDef def = new WorkflowDef();
    def.setSchemaVersion(2);
    Workflow workflowInstance = new Workflow();
    workflowInstance.setWorkflowDefinition(def);
    Map<String, Object> workflowInput = new HashMap<>();
    workflowInput.put(".Id", "22");
    workflowInstance.setInput(workflowInput);
    Map<String, Object> body = new HashMap<>();
    body.put("input", taskDefinitionInput);
    taskDef.getInputTemplate().putAll(body);
    Map<String, Object> evaluatorInput = parametersUtils.getTaskInput(decisionTask.getInputParameters(),
            workflowInstance, taskDef, null);
    expectedException.expect(TerminateWorkflowException.class);
    expectedException.expectMessage("Error while evaluating script: " + decisionTask.getCaseExpression());
    decisionTaskMapper.getEvaluatedCaseValue(decisionTask, evaluatorInput);
}