@Test public void testErrorMessages() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("car_damage_responsibility2.dmn", this.getClass()); assertThat(messages.isEmpty(), is(false)); }
@Test public void testInvalidVariableNames() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("invalid-variable-names.dmn", this.getClass()); assertThat(messages.isEmpty(), is(false)); }
@Test public void testPriority_table_missing_output_values() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("DTABLE_PRIORITY_MISSING_OUTVALS.dmn", this.getClass()); assertThat(messages.size(), is(1)); }
@Test public void testJavaFunctionContext_withErrors() { // DROOLS-1568 final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("java_function_context_with_errors.dmn", this.getClass()); assertThat(messages.size(), is(2)); final List<String> sourceIDs = messages.stream().map(DMNMessage::getSourceId).collect(Collectors.toList()); assertTrue( sourceIDs.contains( "_a72a7aff-48c3-4806-83ca-fc1f1fe34320") ); assertTrue( sourceIDs.contains( "_a72a7aff-48c3-4806-83ca-fc1f1fe34321" ) ); }
@Test public void testMissingInputData() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("missing_input_data.dmn", getClass()); assertThat(messages.get(0).getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL)); } }
@Test public void testUnknownVariable2() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("unknown_variable2.dmn", this.getClass()); assertThat(messages.get(0).getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL)); assertThat(messages.get(0).getMessage(), containsString("Unknown variable 'Borrower.liquidAssetsAmt'")); }
@Test public void testInvalidModel() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("Loan_Prequalification_Condensed_Invalid.dmn", this.getClass()); assertThat(messages.size(), is(2)); assertThat(messages.get(0).getSourceId(), is("_8b5cac9e-c8ca-4817-b05a-c70fa79a8d48")); assertThat(messages.get(1).getSourceId(), is("_ef09d90e-e1a4-4ec9-885b-482d1f4a1cee")); }
@Test public void testWrongTypeRefForDRGElement() { // DROOLS-2917 DMN resolveTypeRef returning null in BKM causes NPE during KieContainer compilation final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongTypeRefForDRGElement.dmn", this.getClass()); DMNRuntimeUtil.formatMessages(messages); assertThat(messages.isEmpty(), is(false)); assertThat(messages.stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.TYPE_DEF_NOT_FOUND)), is(true)); assertThat(messages.stream().anyMatch(m -> m.getSourceId().equals("_561d31ba-a34b-4cf3-b9a4-537e21ce1013")), is(true)); assertThat(messages.stream().anyMatch(m -> m.getSourceId().equals("_45fa8674-f4f0-4c06-b2fd-52bbd17d8550")), is(true)); }
@Test public void testUnknownVariable1() { final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("unknown_variable1.dmn", this.getClass()); assertEquals(1, messages.stream().filter(m -> m.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL)) .filter(m -> m.getMessage().contains("Unknown variable 'NonSalaryPct'")) .count()); }
@Test public void testBoxedInvocationMissingExpression() { // DROOLS-2813 DMN boxed invocation missing expression NPE and Validator issue final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("DROOLS-2813-NPE-BoxedInvocationMissingExpression.dmn", this.getClass()); assertTrue(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION) && p.getSourceId().equals("_a111c4df-c5b5-4d84-81e7-3ec735b50d06"))); }
@Test public void testWrongConstraintsInItemDefinition() { // DROOLS-1503 final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongConstraintsInItemDefinition.dmn", this.getClass()); assertThat(DMNRuntimeUtil.formatMessages(messages), messages.size(), is(3)); assertThat(messages.get(0).getSourceReference(), is(instanceOf(ItemDefinition.class))); assertThat(messages.get(0).getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL)); assertThat(messages.get(1).getSourceId(), is("_e794c655-4fdf-45d1-b7b7-d990df513f92")); assertThat(messages.get(1).getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL)); // The DecisionTable does not define typeRef for the single OutputClause, but neither the enclosing Decision define typeRef for its variable assertThat(messages.get(2).getSourceId(), is("_31911de7-e184-411c-99d1-f33977971270")); assertThat(messages.get(2).getMessageType(), is(DMNMessageType.MISSING_TYPE_REF)); }