LibSassCompiler { protected void writeCss(final Output output) { try { final File outputFile = new File( this.parametersProvider.getOutputUri()); this.logger.info("Write CSS file " + outputFile.getPath()); FileUtils.forceMkdir(outputFile.getParentFile()); FileUtils.write(outputFile, output.getCss(), StandardCharsets.UTF_8); } catch (final IOException e) { this.logger.error("Error writing CSS file", e); } } LibSassCompiler(final Logger logger,
            final PluginParametersProvider parametersProvider); void compileFile();  }
@Test public void writeCss() throws IOException { final File outputFile = this.folder.newFile(); Mockito.when(this.parametersProvider.getOutputUri()) .thenReturn(outputFile.toURI()); final LibSassCompiler compiler = new LibSassCompiler(this.logger, this.parametersProvider); final Output output = new Output("css", null); compiler.writeCss(output); Assert.assertTrue(StringUtils.isNotBlank(FileUtils .readFileToString(outputFile, Charset.defaultCharset()))); Mockito.verify(this.logger, Mockito.never()).error(Mockito.anyString(), Mockito.any(IOException.class)); }
@Test public void writeCss_IOException() throws IOException { final File outputFile = new File( this.folder.getRoot().getAbsolutePath() + File.separator + "/"); Mockito.when(this.parametersProvider.getOutputUri()) .thenReturn(outputFile.toURI()); final LibSassCompiler compiler = new LibSassCompiler(this.logger, this.parametersProvider); final Output output = new Output("css", null); compiler.writeCss(output); Mockito.verify(this.logger, Mockito.times(1)).error(Mockito.anyString(), Mockito.any(IOException.class)); }