@Test public void createReferenceWhenSkinOnDBWithException() throws Exception { when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("wikiId"); DocumentReference skinDocRef = new DocumentReference("wikiId", "XWiki", "MySkin"); when(documentReferenceResolver.resolve(eq("XWiki.MySkin"), eq(new WikiReference("wikiId")))) .thenReturn(skinDocRef); when(xwiki.exists(skinDocRef, xcontext)).thenReturn(true); Exception exception = new XWikiException(); when(xwiki.getDocument(skinDocRef, xcontext)).thenThrow(exception); LESSCompilerException caughtException = null; try { mocker.getComponentUnderTest().createReference("XWiki.MySkin"); } catch(LESSCompilerException e) { caughtException = e; } assertNotNull(caughtException); assertEquals(exception, caughtException.getCause()); assertEquals("Unable to read document [wikiId:XWiki.MySkin]", caughtException.getMessage()); }
@Override public SkinReference createReference(String skinName) throws LESSCompilerException { 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); }
DefaultSkinReferenceFactory implements SkinReferenceFactory { @Override public SkinReference createReference(String skinName) throws LESSCompilerException { 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); } }
DefaultSkinReferenceFactory implements SkinReferenceFactory { @Override public SkinReference createReference(String skinName) throws LESSCompilerException { 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); }  }
DefaultSkinReferenceFactory implements SkinReferenceFactory { @Override public SkinReference createReference(String skinName) throws LESSCompilerException { 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); }  @Override SkinReference createReference(String skinName); @Override SkinReference createReference(DocumentReference documentReference); }
DefaultSkinReferenceFactory implements SkinReferenceFactory { @Override public SkinReference createReference(String skinName) throws LESSCompilerException { 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); }  @Override SkinReference createReference(String skinName); @Override SkinReference createReference(DocumentReference documentReference);  }