use of org.xwiki.lesscss.compiler.LESSCompilerException in project xwiki-platform by xwiki.
the class LessCompilerScriptServiceTest method compileSkinFileWithOtherSkinWhenException.
@Test
public void compileSkinFileWithOtherSkinWhenException() 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, "flamingo", false)).thenThrow(exception);
// Test
String result = mocker.getComponentUnderTest().compileSkinFile("style.less", "flamingo", false);
// Verify
assertEquals("LESSCompilerException: Exception with LESS", result);
}
use of org.xwiki.lesscss.compiler.LESSCompilerException 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);
}
use of org.xwiki.lesscss.compiler.LESSCompilerException in project xwiki-platform by xwiki.
the class LessCompilerScriptServiceTest method getColorThemeFromSkinFileWithException.
@Test
public void getColorThemeFromSkinFileWithException() throws Exception {
// Mocks
Exception exception = new LESSCompilerException("Exception with LESS", null);
when(lessColorThemeConverter.getColorThemeFromSkinFile("style.less", false)).thenThrow(exception);
// Test
ColorTheme result = mocker.getComponentUnderTest().getColorThemeFromSkinFile("style.less");
// Verify
assertEquals(0, result.size());
}
use of org.xwiki.lesscss.compiler.LESSCompilerException in project xwiki-platform by xwiki.
the class LessCompilerScriptServiceTest method getColorThemeFromSkinFileWithOtherSkinAndException.
@Test
public void getColorThemeFromSkinFileWithOtherSkinAndException() throws Exception {
// Mocks
Exception exception = new LESSCompilerException("Exception with LESS", null);
when(lessColorThemeConverter.getColorThemeFromSkinFile("style.less", "flamingo", false)).thenThrow(exception);
// Test
ColorTheme result = mocker.getComponentUnderTest().getColorThemeFromSkinFile("style.less", "flamingo");
// Verify
assertEquals(0, result.size());
}
use of org.xwiki.lesscss.compiler.LESSCompilerException in project xwiki-platform by xwiki.
the class DefaultSkinReferenceFactory method createReference.
@Override
public SkinReference createReference(String skinName) throws LESSCompilerException {
// Get the XWIki Object
XWikiContext xcontext = xcontextProvider.get();
XWiki xwiki = xcontext.getWiki();
String currentWikiId = wikiDescriptorManager.getCurrentWikiId();
DocumentReference skinDocRef = documentReferenceResolver.resolve(skinName, new WikiReference(currentWikiId));
if (xwiki.exists(skinDocRef, xcontext)) {
try {
XWikiDocument skinDoc = xwiki.getDocument(skinDocRef, xcontext);
DocumentReference skinClassDocRef = new DocumentReference(skinDocRef.getWikiReference().getName(), "XWiki", "XWikiSkins");
if (skinDoc.getXObjectSize(skinClassDocRef) > 0) {
return createReference(skinDocRef);
}
} catch (XWikiException e) {
throw new LESSCompilerException(String.format("Unable to read document [%s]", skinDocRef), e);
}
}
return new FSSkinReference(skinName);
}
Aggregations