use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class Check1stNFViolationTest method testCheck1stNFViolationCollect.
@Test
public void testCheck1stNFViolationCollect() {
List<DMNMessage> validate = validator.validate(getReader("DT1stNFViolationCollect.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysisDuplicate = getAnalysis(validate, "_4237d55b-2589-48a5-8183-f9f4e0e00c07");
assertThat(analysisDuplicate.is1stNFViolation(), is(true));
assertThat(analysisDuplicate.getDuplicateRulesTuples(), hasSize(2));
assertTrue("It should contain DMNMessage(s) for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_4237d55b-2589-48a5-8183-f9f4e0e00c07") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
assertTrue("Being a C table, DMNMessage(s) for the 1st NF Violation are of type Warning", validate.stream().filter(p -> p.getSourceId().equals("_4237d55b-2589-48a5-8183-f9f4e0e00c07") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)).allMatch(p -> p.getLevel() == Level.WARNING));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class Check1stNFViolationTest method testCheck1stNFViolation.
@Test
public void testCheck1stNFViolation() {
List<DMNMessage> validate = validator.validate(getReader("DT1stNFViolation.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysisDuplicate = getAnalysis(validate, "_053034d5-0e1f-4c4a-8513-ab3c6ba538db");
assertThat(analysisDuplicate.is1stNFViolation(), is(true));
assertThat(analysisDuplicate.getDuplicateRulesTuples(), hasSize(1));
assertThat(analysisDuplicate.getDuplicateRulesTuples(), contains(Collections.singletonList(Arrays.asList(1, 2)).toArray()));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_053034d5-0e1f-4c4a-8513-ab3c6ba538db") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
DTAnalysis analysisFIRST = getAnalysis(validate, "_1ca6acde-c1d4-4c50-8e21-f3b11e106f3d");
assertThat(analysisFIRST.is1stNFViolation(), is(true));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_1ca6acde-c1d4-4c50-8e21-f3b11e106f3d") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
DTAnalysis analysisRULE_ORDER = getAnalysis(validate, "_03522945-b520-4b45-ac5e-ef3cbd7f1eaf");
assertThat(analysisRULE_ORDER.is1stNFViolation(), is(true));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getSourceId().equals("_03522945-b520-4b45-ac5e-ef3cbd7f1eaf") && p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class Check1stNFViolationTest method testCheck1stNFViolationDuplicateNoSubsumption.
@Test
public void testCheck1stNFViolationDuplicateNoSubsumption() {
List<DMNMessage> validate = validator.validate(getReader("DT1stNFViolationDuplicateNoSubsumption.dmn"), ANALYZE_DECISION_TABLE);
DTAnalysis analysis = getAnalysis(validate, "_221BF4A4-F8D4-466C-96E4-311FE3C9867B");
assertThat(analysis.is1stNFViolation(), is(true));
assertThat(analysis.getDuplicateRulesTuples(), hasSize(1));
assertThat(analysis.getDuplicateRulesTuples(), contains(Collections.singletonList(Arrays.asList(1, 2)).toArray()));
assertTrue("It should contain at DMNMessage for the 1st NF Violation", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_1STNFVIOLATION)));
assertThat(analysis.getSubsumptions().isEmpty(), is(false));
assertTrue("No message about subsumption", validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_SUBSUMPTION_RULE)));
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class OverlapHitPolicyTest method testOverlapHitPolicy.
@Test
public void testOverlapHitPolicy() {
Definitions definitions = getDefinitions("OverlapHitPolicy.dmn", "https://github.com/kiegroup/drools/kie-dmn/_3010653A-DD3F-4C88-89DA-3FDD845F6604", "OverlapHitPolicy");
// mutates XML file in the Hit Policy, accordingly to this test parameter.
((DecisionTable) ((Decision) definitions.getDrgElement().get(0)).getExpression()).setHitPolicy(hp);
List<DMNMessage> validate = validator.validate(definitions, VALIDATE_COMPILATION, ANALYZE_DECISION_TABLE);
checkAnalysis(validate);
if (hp == HitPolicy.UNIQUE) {
assertTrue("It should contain at least 1 DMNMessage for the type", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_UNIQUE)));
} else if (hp == HitPolicy.ANY) {
assertTrue("It should contain at least 1 DMNMessage for the type", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_ANY)));
} else {
LOG.debug("Testing for {} I am expecting there is NOT DMNMessage pertaining to Overlaps", hp);
assertTrue(validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_UNIQUE)) && validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP_HITPOLICY_ANY)) && validate.stream().noneMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_OVERLAP)));
}
}
use of org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE in project drools by kiegroup.
the class SimpleStringNoGapTest method test.
@Test
public void test() {
List<DMNMessage> validate = validator.validate(getReader("simpleStringNoGap.dmn"), VALIDATE_COMPILATION, VALIDATE_MODEL, ANALYZE_DECISION_TABLE);
// Gap Analysis skipped because of free string.
assertThat(validate, hasSize(1));
assertTrue("It should contain DMNMessage for the skipped gap analysis", validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.DECISION_TABLE_GAP)));
debugValidatorMsg(validate);
DTAnalysis analysis = getAnalysis(validate, "_3D5BDDEF-8B71-4797-8662-5026A9C2A112");
assertThat(analysis.getGaps(), hasSize(0));
assertThat(analysis.getOverlaps(), hasSize(0));
}
Aggregations