@Test public void testUnprotectedRecordStructures() throws Exception { final Set<Violation> violations = new RecordStructureDeclarationRules( toDocument("unprotected-record-structure-declarations.xml")).doMeasuredAnalysis(); assertThat(violations).hasSize(2); assertThat(violations).contains(new UnprotectedRecordStructureDefinitionViolation("REC1", 3)); assertThat(violations).contains(new UnprotectedRecordStructureDefinitionViolation("REC2", 8)); }
@Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> records = selectNodesByName("RECORD."); final List<Element> frees = selectNodesByName("Z_FREE."); for (final Element record : records) { final String recordName = getCclName(record.getChild("COMMA.")); for (final Element listOrStruct : selectNodesByName(record, "FIELD.", "[OCCUR. or not(FORMAT.)]")) { if (listOrStruct.getChildren("FIELD.").size() == 0) { violations.add(new EmptyListOrStructureDefinitionViolation(recordName, getCclName(listOrStruct), getLineNumber(listOrStruct))); } } if (recordStructureHasNoDefinedScoping(record)) { violations.add(new UnprotectedRecordStructureDefinitionViolation(recordName, getLineNumber(record))); } for (final Element free : frees) { if (getCclName(free).equalsIgnoreCase(recordName)) { violations.add(new FreedRecordStructureViolation(recordName, getLineNumber(free))); break; } } } return violations; }
RecordStructureDeclarationRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> records = selectNodesByName("RECORD."); final List<Element> frees = selectNodesByName("Z_FREE."); for (final Element record : records) { final String recordName = getCclName(record.getChild("COMMA.")); for (final Element listOrStruct : selectNodesByName(record, "FIELD.", "[OCCUR. or not(FORMAT.)]")) { if (listOrStruct.getChildren("FIELD.").size() == 0) { violations.add(new EmptyListOrStructureDefinitionViolation(recordName, getCclName(listOrStruct), getLineNumber(listOrStruct))); } } if (recordStructureHasNoDefinedScoping(record)) { violations.add(new UnprotectedRecordStructureDefinitionViolation(recordName, getLineNumber(record))); } for (final Element free : frees) { if (getCclName(free).equalsIgnoreCase(recordName)) { violations.add(new FreedRecordStructureViolation(recordName, getLineNumber(free))); break; } } } return violations; } }
RecordStructureDeclarationRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> records = selectNodesByName("RECORD."); final List<Element> frees = selectNodesByName("Z_FREE."); for (final Element record : records) { final String recordName = getCclName(record.getChild("COMMA.")); for (final Element listOrStruct : selectNodesByName(record, "FIELD.", "[OCCUR. or not(FORMAT.)]")) { if (listOrStruct.getChildren("FIELD.").size() == 0) { violations.add(new EmptyListOrStructureDefinitionViolation(recordName, getCclName(listOrStruct), getLineNumber(listOrStruct))); } } if (recordStructureHasNoDefinedScoping(record)) { violations.add(new UnprotectedRecordStructureDefinitionViolation(recordName, getLineNumber(record))); } for (final Element free : frees) { if (getCclName(free).equalsIgnoreCase(recordName)) { violations.add(new FreedRecordStructureViolation(recordName, getLineNumber(free))); break; } } } return violations; } RecordStructureDeclarationRules(final Document document); }
RecordStructureDeclarationRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> records = selectNodesByName("RECORD."); final List<Element> frees = selectNodesByName("Z_FREE."); for (final Element record : records) { final String recordName = getCclName(record.getChild("COMMA.")); for (final Element listOrStruct : selectNodesByName(record, "FIELD.", "[OCCUR. or not(FORMAT.)]")) { if (listOrStruct.getChildren("FIELD.").size() == 0) { violations.add(new EmptyListOrStructureDefinitionViolation(recordName, getCclName(listOrStruct), getLineNumber(listOrStruct))); } } if (recordStructureHasNoDefinedScoping(record)) { violations.add(new UnprotectedRecordStructureDefinitionViolation(recordName, getLineNumber(record))); } for (final Element free : frees) { if (getCclName(free).equalsIgnoreCase(recordName)) { violations.add(new FreedRecordStructureViolation(recordName, getLineNumber(free))); break; } } } return violations; } RecordStructureDeclarationRules(final Document document); @Override Set<Violation> getCheckedViolations(); }
RecordStructureDeclarationRules extends TimedDelegate { @Override protected Set<Violation> doMeasuredAnalysis() throws JDOMException { final Set<Violation> violations = new HashSet<Violation>(); final List<Element> records = selectNodesByName("RECORD."); final List<Element> frees = selectNodesByName("Z_FREE."); for (final Element record : records) { final String recordName = getCclName(record.getChild("COMMA.")); for (final Element listOrStruct : selectNodesByName(record, "FIELD.", "[OCCUR. or not(FORMAT.)]")) { if (listOrStruct.getChildren("FIELD.").size() == 0) { violations.add(new EmptyListOrStructureDefinitionViolation(recordName, getCclName(listOrStruct), getLineNumber(listOrStruct))); } } if (recordStructureHasNoDefinedScoping(record)) { violations.add(new UnprotectedRecordStructureDefinitionViolation(recordName, getLineNumber(record))); } for (final Element free : frees) { if (getCclName(free).equalsIgnoreCase(recordName)) { violations.add(new FreedRecordStructureViolation(recordName, getLineNumber(free))); break; } } } return violations; } RecordStructureDeclarationRules(final Document document); @Override Set<Violation> getCheckedViolations();  }