LibSassCompiler { protected Output launchCompilation() throws CompilationException { if (this.logger.isInfoEnabled()) { this.logger.info("Launching compilation"); } final io.bit3.jsass.Compiler compiler = new io.bit3.jsass.Compiler(); try { final Output output = compiler.compileFile( this.parametersProvider.getInputUri(), this.parametersProvider.getOutputUri(), this.options); if (this.logger.isInfoEnabled()) { this.logger.info("End of compilation"); } return output; } catch (final CompilationException compilationException) { this.logger.error(compilationException.getErrorFile()); this.logger.error(compilationException.getErrorJson()); this.logger.error(compilationException.getErrorMessage()); this.logger.error(compilationException.getErrorSrc()); this.logger.error(compilationException.getErrorText()); throw compilationException; } } LibSassCompiler(final Logger logger,
            final PluginParametersProvider parametersProvider); void compileFile();  }
@Test public void launchCompilation_Empty_File() throws IOException, CompilationException { final LibSassCompiler compiler = new LibSassCompiler(this.logger, this.parametersProvider); final Output output = compiler.launchCompilation(); Assert.assertTrue(output.getCss() != null); Assert.assertTrue(StringUtils.isBlank(output.getCss())); Mockito.verify(this.logger, Mockito.never()).error(Mockito.anyString()); }
@Test public void launchCompilation_Minimal_Css() throws IOException, CompilationException { final LibSassCompiler compiler = new LibSassCompiler(this.logger, this.parametersProvider); final File inputFile = this.folder.newFile("input"); final String cssText = "body{text-align:left;}"; FileUtils.write(inputFile, cssText, Charset.defaultCharset()); Mockito.when(this.parametersProvider.getInputUri()) .thenReturn(inputFile.toURI()); final Output output = compiler.launchCompilation(); Assert.assertTrue(StringUtils.isNotBlank(output.getCss())); Mockito.verify(this.logger, Mockito.never()).error(Mockito.anyString()); }
@Test(expected = CompilationException.class) public void launchCompilation_Incorrect_Css() throws IOException, CompilationException { final LibSassCompiler compiler = new LibSassCompiler(this.logger, this.parametersProvider); final File inputFile = this.folder.newFile("input"); final String cssText = "body{"; FileUtils.write(inputFile, cssText, Charset.defaultCharset()); Mockito.when(this.parametersProvider.getInputUri()) .thenReturn(inputFile.toURI()); final Output output = compiler.launchCompilation(); Assert.assertTrue(StringUtils.isBlank(output.getCss())); Mockito.verify(this.logger, Mockito.times(5)) .error(Mockito.anyString()); }