Search in sources :

Example 1 with DocumentSkinReference

use of org.xwiki.lesscss.internal.skin.DocumentSkinReference in project xwiki-platform by xwiki.

the class SkinListenerTest method onEventWhenSkinIsChanged.

@Test
public void onEventWhenSkinIsChanged() throws Exception {
    // Mocks
    Event event = mock(Event.class);
    XWikiDocument doc = mock(XWikiDocument.class);
    Object data = new Object();
    EntityReference classReference = new LocalDocumentReference("XWiki", "XWikiSkins");
    List<BaseObject> objects = new ArrayList<>();
    BaseObject object = mock(BaseObject.class);
    objects.add(object);
    when(doc.getXObjects(classReference)).thenReturn(objects);
    DocumentReference documentReference = new DocumentReference("wiki", "space", "page");
    when(doc.getDocumentReference()).thenReturn(documentReference);
    DocumentSkinReference skinReference = new DocumentSkinReference(documentReference, null);
    when(skinReferenceFactory.createReference(documentReference)).thenReturn(skinReference);
    // Test
    mocker.getComponentUnderTest().onEvent(event, doc, data);
    // Verify
    verify(lessResourcesCache).clearFromSkin(skinReference);
    verify(colorThemeCache).clearFromSkin(skinReference);
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) EntityReference(org.xwiki.model.reference.EntityReference) ArrayList(java.util.ArrayList) DocumentCreatedEvent(org.xwiki.bridge.event.DocumentCreatedEvent) DocumentUpdatedEvent(org.xwiki.bridge.event.DocumentUpdatedEvent) Event(org.xwiki.observation.event.Event) DocumentDeletedEvent(org.xwiki.bridge.event.DocumentDeletedEvent) BaseObject(com.xpn.xwiki.objects.BaseObject) DocumentSkinReference(org.xwiki.lesscss.internal.skin.DocumentSkinReference) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject) Test(org.junit.Test)

Aggregations

XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)1 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)1 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)1 DocumentSkinReference (org.xwiki.lesscss.internal.skin.DocumentSkinReference)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 EntityReference (org.xwiki.model.reference.EntityReference)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 Event (org.xwiki.observation.event.Event)1