@Test public void compile() throws Exception { when(skinManager.getSkin("skin")).thenReturn(skin); when(skin.getResource("less/style.less.vm")).thenReturn(mock(Resource.class)); StringWriter import1source = new StringWriter(); IOUtils.copy(new FileInputStream(getClass().getResource("/style.less.vm").getFile()), import1source); when(templateManager.renderFromSkin("less/style.less.vm", skin)).thenReturn(import1source.toString()); when(skin.getResource("less/subdir/import2.less")).thenReturn(mock(Resource.class)); Template import2 = mock(Template.class); when(templateManager.getTemplate("less/subdir/import2.less", skin)).thenReturn(import2); TemplateContent importContent2 = mock(TemplateContent.class); when(import2.getContent()).thenReturn(importContent2); StringWriter import2source = new StringWriter(); IOUtils.copy(new FileInputStream(getClass().getResource("/import2.less").getFile()), import2source); when(importContent2.getContent()).thenReturn(import2source.toString()); when(skin.getResource("less/subdir/import3.less")).thenReturn(mock(Resource.class)); Template import3 = mock(Template.class); when(templateManager.getTemplate("less/subdir/import3.less", skin)).thenReturn(import3); TemplateContent importContent3 = mock(TemplateContent.class); when(import3.getContent()).thenReturn(importContent3); StringWriter import3source = new StringWriter(); IOUtils.copy(new FileInputStream(getClass().getResource("/import3.less").getFile()), import3source); when(importContent3.getContent()).thenReturn(import3source.toString()); StringWriter source = new StringWriter(); IOUtils.copy(new FileInputStream(getClass().getResource("/style3.less").getFile()), source); String result = mocker.getComponentUnderTest().compile(source.toString(), "skin", false); String result2 = mocker.getComponentUnderTest().compile(source.toString(), "skin", true); StringWriter expected = new StringWriter(); IOUtils.copy(new FileInputStream(getClass().getResource("/style3.css").getFile()), expected); assertEquals(expected.toString(), result); assertTrue(result2.contains("/*# sourceMappingURL=data:application/json;base64,")); }
public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException { LessCompiler lessCompiler = new DefaultLessCompiler(); LessCompiler.Configuration options = new LessCompiler.Configuration(); options.setCompressing(true); options.getSourceMapConfiguration().setInline(inlineSourceMap); options.getSourceMapConfiguration().setIncludeSourcesContent(true); LessSource lessSource = new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin)); LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options); return lessResult.getCss(); }
Less4jCompiler { public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException { LessCompiler lessCompiler = new DefaultLessCompiler(); LessCompiler.Configuration options = new LessCompiler.Configuration(); options.setCompressing(true); options.getSourceMapConfiguration().setInline(inlineSourceMap); options.getSourceMapConfiguration().setIncludeSourcesContent(true); LessSource lessSource = new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin)); LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options); return lessResult.getCss(); } }
Less4jCompiler { public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException { LessCompiler lessCompiler = new DefaultLessCompiler(); LessCompiler.Configuration options = new LessCompiler.Configuration(); options.setCompressing(true); options.getSourceMapConfiguration().setInline(inlineSourceMap); options.getSourceMapConfiguration().setIncludeSourcesContent(true); LessSource lessSource = new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin)); LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options); return lessResult.getCss(); }  }
Less4jCompiler { public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException { LessCompiler lessCompiler = new DefaultLessCompiler(); LessCompiler.Configuration options = new LessCompiler.Configuration(); options.setCompressing(true); options.getSourceMapConfiguration().setInline(inlineSourceMap); options.getSourceMapConfiguration().setIncludeSourcesContent(true); LessSource lessSource = new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin)); LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options); return lessResult.getCss(); }  String compile(String lessCode, String skin, boolean inlineSourceMap); }
Less4jCompiler { public String compile(String lessCode, String skin, boolean inlineSourceMap) throws Less4jException { LessCompiler lessCompiler = new DefaultLessCompiler(); LessCompiler.Configuration options = new LessCompiler.Configuration(); options.setCompressing(true); options.getSourceMapConfiguration().setInline(inlineSourceMap); options.getSourceMapConfiguration().setIncludeSourcesContent(true); LessSource lessSource = new CustomContentLESSSource(lessCode, templateManager, skinManager.getSkin(skin)); LessCompiler.CompilationResult lessResult = lessCompiler.compile(lessSource, options); return lessResult.getCss(); }  String compile(String lessCode, String skin, boolean inlineSourceMap);  }