XmlProcessingInstructionParser { public void scanForIgnoredSections(String originalXml) { this.originalXml = originalXml; SortpomPiScanner sortpomPiScanner = new SortpomPiScanner(logger); sortpomPiScanner.scan(originalXml); if (sortpomPiScanner.isScanError()) { throw new FailureException(sortpomPiScanner.getFirstError()); } containsIgnoredSections = sortpomPiScanner.containsIgnoredSections(); }  void setup(SortPomLogger logger); void scanForIgnoredSections(String originalXml); boolean existsIgnoredSections(); String replaceIgnoredSections(); String revertIgnoredSections(String sortedXml);  }
@Test void multipleErrorsShouldBeReportedInLogger() { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http: " <artifactId>sortpom</artifactId>\n" + " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n" + " <groupId>sortpom</groupId>\n" + " <modelVersion>4.0.0</modelVersion>\n" + " <name>SortPom</name>\n" + " <!-- Egenskaper för projektet -->\n" + " <properties>\n" + " <?sortpom resume?>" + "<compileSource>1.6</compileSource>\n" + " <?sortpom ignore?>" + " <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" + " <?sortpom resume?>" + " </properties>\n" + " <?sortpom token='0'?>" + " <?sortpom gurka?>" + " <reporting />\n" + " <?sortpom ignore?>" + " <version>1.0.0-SNAPSHOT</version>\n" + "</project>"; final Executable testMethod = () -> parser.scanForIgnoredSections(xml); final FailureException thrown = assertThrows(FailureException.class, testMethod); assertThat(thrown.getMessage(), is("Xml contained unexpected sortpom instruction 'resume'. Please use expected instruction <?sortpom IGNORE?>")); verify(logger).error("Xml contained unexpected sortpom instruction 'resume'. Please use expected instruction <?sortpom IGNORE?>"); verify(logger).error("Xml contained unknown sortpom instruction 'token='0''. Please use <?sortpom IGNORE?> or <?sortpom RESUME?>"); verify(logger).error("Xml contained unknown sortpom instruction 'gurka'. Please use <?sortpom IGNORE?> or <?sortpom RESUME?>"); verify(logger).error("Xml processing instructions for sortpom was not properly terminated. Every <?sortpom IGNORE?> must be followed with <?sortpom RESUME?>"); verifyNoMoreInteractions(logger); }