DocFileWriter { @SuppressWarnings("squid:S1166") public void writeDocFile(String pluginName, String doc) { createOutputDir(); File outputFile = new File(outputDir, pluginName + ".adoc"); try { Files.asCharSink(outputFile, Charset.defaultCharset()).write(doc); } catch (IOException e) { errorLogger.logError("Can't write to file " + outputFile.getAbsolutePath()); } } DocFileWriter(AnnotationProcessorErrorLogger errorLogger, String outputDir); @SuppressWarnings("squid:S1166") // log or rethrow exception. Which is exactly what happens. void writeDocFile(String pluginName, String doc);  }
@Test public void testWriteDocFile() throws IOException { DocFileWriter docFileWriter = new DocFileWriter(errorLogger, outputDirName); assertThat(outputDir.exists(), is(false)); docFileWriter.writeDocFile("MyPlugin", "mydoc\nand so on"); assertThat(outputDir.exists(), is(true)); File file = new File(this.outputDirName, "MyPlugin.adoc"); assertThat(file.exists(), is(true)); List<String> lines = Files.readLines(file, Charset.defaultCharset()); assertThat(lines.size(), is(2)); assertThat(lines.get(0), is("mydoc")); assertThat(lines.get(1), is("and so on")); }