@Test void should_dump_xml_report() throws IOException { when(fs.workDir()).thenReturn(WORK_DIR); settings.setProperty(PmdConfiguration.PROPERTY_GENERATE_XML, true); Path reportFile = configuration.dumpXmlReport(new Report()); assertThat(reportFile.toFile()).isEqualTo(new File(WORK_DIR, "pmd-result.xml")); List<String> writtenLines = Files.readAllLines(reportFile, StandardCharsets.UTF_8); assertThat(writtenLines).hasSize(6); assertThat(writtenLines.get(1)).contains("<pmd"); }
Path dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML).orElse(false)) { return null; } try { final String reportAsString = reportToString(report); final Path reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.toString()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } }
PmdConfiguration { Path dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML).orElse(false)) { return null; } try { final String reportAsString = reportToString(report); final Path reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.toString()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } }
PmdConfiguration { Path dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML).orElse(false)) { return null; } try { final String reportAsString = reportToString(report); final Path reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.toString()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } PmdConfiguration(FileSystem fileSystem, Configuration settings); }
PmdConfiguration { Path dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML).orElse(false)) { return null; } try { final String reportAsString = reportToString(report); final Path reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.toString()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } PmdConfiguration(FileSystem fileSystem, Configuration settings);  }
PmdConfiguration { Path dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML).orElse(false)) { return null; } try { final String reportAsString = reportToString(report); final Path reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.toString()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } PmdConfiguration(FileSystem fileSystem, Configuration settings);   }