Search in sources :

Example 11 with LESSResourceReference

use of org.xwiki.lesscss.resources.LESSResourceReference in project xwiki-platform by xwiki.

the class LessCompilerScriptServiceTest method compileSkinFileWhenException.

@Test
public void compileSkinFileWhenException() throws Exception {
    // Mocks
    LESSResourceReference style = mock(LESSResourceReference.class);
    when(lessResourceReferenceFactory.createReferenceForSkinFile("style.less")).thenReturn(style);
    Exception exception = new LESSCompilerException("Exception with LESS", null);
    when(lessCompiler.compile(style, false, true, false)).thenThrow(exception);
    // Test
    String result = mocker.getComponentUnderTest().compileSkinFile("style.less", false);
    // Verify
    assertEquals("LESSCompilerException: Exception with LESS", result);
}
Also used : LESSResourceReference(org.xwiki.lesscss.resources.LESSResourceReference) LESSCompilerException(org.xwiki.lesscss.compiler.LESSCompilerException) LESSCompilerException(org.xwiki.lesscss.compiler.LESSCompilerException) Test(org.junit.Test)

Example 12 with LESSResourceReference

use of org.xwiki.lesscss.resources.LESSResourceReference in project xwiki-platform by xwiki.

the class LessCompilerScriptServiceTest method compileSkinFile.

@Test
public void compileSkinFile() throws Exception {
    // Mock
    LESSResourceReference style = mock(LESSResourceReference.class);
    when(lessResourceReferenceFactory.createReferenceForSkinFile("style.less")).thenReturn(style);
    // Test
    mocker.getComponentUnderTest().compileSkinFile("style.less");
    // Verify
    verify(lessCompiler).compile(style, false, true, false);
    // Mock
    LESSResourceReference style2 = mock(LESSResourceReference.class);
    when(lessResourceReferenceFactory.createReferenceForSkinFile("style2.less")).thenReturn(style2);
    // Test
    mocker.getComponentUnderTest().compileSkinFile("style2.less", true);
    // Verify
    verify(lessCompiler).compile(style2, false, true, true);
    // Mock
    LESSResourceReference style3 = mock(LESSResourceReference.class);
    when(lessResourceReferenceFactory.createReferenceForSkinFile("style3.less")).thenReturn(style3);
    // Test
    mocker.getComponentUnderTest().compileSkinFile("style3.less", false);
    // Verify
    verify(lessCompiler).compile(style3, false, true, false);
}
Also used : LESSResourceReference(org.xwiki.lesscss.resources.LESSResourceReference) Test(org.junit.Test)

Example 13 with LESSResourceReference

use of org.xwiki.lesscss.resources.LESSResourceReference in project xwiki-platform by xwiki.

the class CacheKeyFactoryTest method getCacheKeyWithContext.

@Test
public void getCacheKeyWithContext() throws Exception {
    // Mocks
    LESSResourceReference lessResource = mock(LESSResourceReference.class);
    SkinReference skin = mock(SkinReference.class);
    ColorThemeReference colorTheme = mock(ColorThemeReference.class);
    when(lessResource.serialize()).thenReturn("lessResource");
    when(skin.serialize()).thenReturn("skin");
    when(colorTheme.serialize()).thenReturn("colorTheme");
    when(xcontextCacheKeyFactory.getCacheKey()).thenReturn("XWikiContext[Mock]");
    // Test
    assertEquals("12_lessResource_4_skin_10_colorTheme_18_XWikiContext[Mock]", mocker.getComponentUnderTest().getCacheKey(lessResource, skin, colorTheme, true));
}
Also used : ColorThemeReference(org.xwiki.lesscss.internal.colortheme.ColorThemeReference) SkinReference(org.xwiki.lesscss.internal.skin.SkinReference) LESSResourceReference(org.xwiki.lesscss.resources.LESSResourceReference) Test(org.junit.Test)

Example 14 with LESSResourceReference

use of org.xwiki.lesscss.resources.LESSResourceReference in project xwiki-platform by xwiki.

the class CacheKeyFactoryTest method getCacheKeyWithoutContext.

@Test
public void getCacheKeyWithoutContext() throws Exception {
    // Mocks
    LESSResourceReference lessResource = mock(LESSResourceReference.class);
    SkinReference skin = mock(SkinReference.class);
    ColorThemeReference colorTheme = mock(ColorThemeReference.class);
    when(lessResource.serialize()).thenReturn("lessResource");
    when(skin.serialize()).thenReturn("skin");
    when(colorTheme.serialize()).thenReturn("colorTheme");
    // Test
    assertEquals("12_lessResource_4_skin_10_colorTheme", mocker.getComponentUnderTest().getCacheKey(lessResource, skin, colorTheme, false));
}
Also used : ColorThemeReference(org.xwiki.lesscss.internal.colortheme.ColorThemeReference) SkinReference(org.xwiki.lesscss.internal.skin.SkinReference) LESSResourceReference(org.xwiki.lesscss.resources.LESSResourceReference) Test(org.junit.Test)

Aggregations

LESSResourceReference (org.xwiki.lesscss.resources.LESSResourceReference)14 Test (org.junit.Test)12 LESSCompilerException (org.xwiki.lesscss.compiler.LESSCompilerException)5 BaseObject (com.xpn.xwiki.objects.BaseObject)2 ColorThemeReference (org.xwiki.lesscss.internal.colortheme.ColorThemeReference)2 SkinReference (org.xwiki.lesscss.internal.skin.SkinReference)2 ObjectPropertyReference (org.xwiki.model.reference.ObjectPropertyReference)2 Less4jException (com.github.sommeri.less4j.Less4jException)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 BaseObjectReference (com.xpn.xwiki.objects.BaseObjectReference)1 StringWriter (java.io.StringWriter)1 VelocityContext (org.apache.velocity.VelocityContext)1 LESSCompiler (org.xwiki.lesscss.compiler.LESSCompiler)1 LESSResourceReferenceFactory (org.xwiki.lesscss.resources.LESSResourceReferenceFactory)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 VelocityManager (org.xwiki.velocity.VelocityManager)1 XWikiVelocityException (org.xwiki.velocity.XWikiVelocityException)1