### Question:
RuleDescriptionValidator extends SimpleDMNValidator { @Override public List<String> validate(DMNModelRepository dmnModelRepository) { List<String> errors = new ArrayList<>(); if (dmnModelRepository == null) { throw new IllegalArgumentException("Missing definitions"); } for (TDefinitions definitions: dmnModelRepository.getAllDefinitions()) { for (TDecision decision : dmnModelRepository.findDecisions(definitions)) { TExpression expression = dmnModelRepository.expression(decision); if (expression instanceof TDecisionTable) { List<TDecisionRule> rules = ((TDecisionTable) expression).getRule(); for (int i = 0; i < rules.size(); i++) { TDecisionRule rule = rules.get(i); validate(rule.getDescription(), i, decision, errors); } } } } return errors; } RuleDescriptionValidator();  RuleDescriptionValidator(BuildLogger logger); @Override List<String> validate(DMNModelRepository dmnModelRepository);  }### Answer:
@Test public void testValidate() { String path = "dmn2java/exported/complex/input/"; String diagramName = "Linked Decision Test.dmn"; List<String> expectedErrors = Arrays.asList( "Description of rule 0 in decision 'assessApplicantAge' contains illegal sequence 'string(-)'", "Description of rule 1 in decision 'assessApplicantAge' contains illegal sequence 'string(-)'", "Description of rule 2 in decision 'assessApplicantAge' contains illegal sequence 'string(-)'", "Description of rule 0 in decision 'makeCreditDecision' contains illegal sequence 'string(-)'", "Description of rule 1 in decision 'makeCreditDecision' contains illegal sequence 'string(-)'", "Description of rule 2 in decision 'makeCreditDecision' contains illegal sequence 'string(-)'", "Description of rule 0 in decision 'processPriorIssues' contains illegal sequence 'string(-)'", "Description of rule 1 in decision 'processPriorIssues' contains illegal sequence 'string(-)'", "Description of rule 2 in decision 'processPriorIssues' contains illegal sequence 'string(-)'", "Description of rule 3 in decision 'processPriorIssues' contains illegal sequence 'string(-)'", "Description of rule 4 in decision 'processPriorIssues' contains illegal sequence 'string(-)'", "Description of rule 0 in decision 'root' contains illegal sequence 'string(-)'", "Description of rule 1 in decision 'root' contains illegal sequence 'string(-)'", "Description of rule 2 in decision 'root' contains illegal sequence 'string(-)'", "Description of rule 3 in decision 'root' contains illegal sequence 'string(-)'" ); validate(validator, path + diagramName, expectedErrors); }
@Test public void testValidateIncorrectList() { String description = "[ , string(\"abc\" , , string(\"abc\") , ]"; List<String> actualErrors = new ArrayList<>(); validator.validate(description, 0, makeDecision(), actualErrors); List<String> expectedErrors = Arrays.asList( "Description of rule 0 in decision 'Test' contains illegal sequence '[ ,'", "Description of rule 0 in decision 'Test' contains illegal sequence ', ,'", "Description of rule 0 in decision 'Test' contains illegal sequence ', ]'" ); assertEquals(expectedErrors, actualErrors); }
@Test public void testValidateIncorrectStrings() { String description = "[ string(-) ]"; List<String> actualErrors = new ArrayList<>(); validator.validate(description, 0, makeDecision(), actualErrors); List<String> expectedErrors = Arrays.asList( "Description of rule 0 in decision 'Test' contains illegal sequence 'string(-)'" ); assertEquals(expectedErrors, actualErrors); }
@Test public void testValidateIncorrectCharacters() { String description = "[ string(\"\") , string(\"abc \u00A0 123\") , string(\"\") ]"; List<String> actualErrors = new ArrayList<>(); validator.validate(description, 0, makeDecision(), actualErrors); List<String> expectedErrors = Arrays.asList( "Description of rule 0 in decision 'Test' contains illegal sequence 'NO-BREAK SPACE'" ); assertEquals(expectedErrors, actualErrors); }