@Test public void should_dump_xml_report() throws IOException { when(fs.workDir()).thenReturn(WORK_DIR); settings.setProperty(PmdConfiguration.PROPERTY_GENERATE_XML, true); File reportFile = configuration.dumpXmlReport(new Report()); assertThat(reportFile).isEqualTo(new File(WORK_DIR, "pmd-result.xml")); List<String> writtenLines = Files.readLines(reportFile, Charsets.UTF_8); assertThat(writtenLines).hasSize(3); assertThat(writtenLines.get(1)).contains("<pmd"); }
public File dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML)) { return null; } try { String reportAsString = reportToString(report); File reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.getAbsolutePath()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } }
PmdConfiguration implements BatchExtension { public File dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML)) { return null; } try { String reportAsString = reportToString(report); File reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.getAbsolutePath()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } }
PmdConfiguration implements BatchExtension { public File dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML)) { return null; } try { String reportAsString = reportToString(report); File reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.getAbsolutePath()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } PmdConfiguration(FileSystem fileSystem, Settings settings); }
PmdConfiguration implements BatchExtension { public File dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML)) { return null; } try { String reportAsString = reportToString(report); File reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.getAbsolutePath()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } PmdConfiguration(FileSystem fileSystem, Settings settings); File dumpXmlRuleSet(String repositoryKey, String rulesXml); File dumpXmlReport(Report report); }
PmdConfiguration implements BatchExtension { public File dumpXmlReport(Report report) { if (!settings.getBoolean(PROPERTY_GENERATE_XML)) { return null; } try { String reportAsString = reportToString(report); File reportFile = writeToWorkingDirectory(reportAsString, PMD_RESULT_XML); LOG.info("PMD output report: " + reportFile.getAbsolutePath()); return reportFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD report", e); } } PmdConfiguration(FileSystem fileSystem, Settings settings); File dumpXmlRuleSet(String repositoryKey, String rulesXml); File dumpXmlReport(Report report); static final String PROPERTY_GENERATE_XML; static final String PMD_RESULT_XML; }