### Question:
PmdConfiguration { File dumpXmlRuleSet(String repositoryKey, String rulesXml) { try { File configurationFile = writeToWorkingDirectory(rulesXml, repositoryKey + ".xml").toFile(); LOG.info("PMD configuration: " + configurationFile.getAbsolutePath()); return configurationFile; } catch (IOException e) { throw new IllegalStateException("Fail to save the PMD configuration", e); } } PmdConfiguration(FileSystem fileSystem, Configuration settings);   }### Answer:
@Test void should_dump_xml_rule_set() throws IOException { when(fs.workDir()).thenReturn(WORK_DIR); File rulesFile = configuration.dumpXmlRuleSet("pmd", "<rules>"); assertThat(rulesFile).isEqualTo(new File(WORK_DIR, "pmd.xml")); assertThat(Files.readAllLines(rulesFile.toPath(), StandardCharsets.UTF_8)).containsExactly("<rules>"); }
@Test void should_fail_to_dump_xml_rule_set() { when(fs.workDir()).thenReturn(new File("xxx")); final Throwable thrown = catchThrowable(() -> configuration.dumpXmlRuleSet("pmd", "<xml>")); assertThat(thrown) .isInstanceOf(IllegalStateException.class) .hasMessage("Fail to save the PMD configuration"); }