Search in sources :

Example 1 with DocumentColorThemeReference

use of org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference in project xwiki-platform by xwiki.

the class ColorThemeListenerTest method onEventWhenColorThemeChanged.

@Test
public void onEventWhenColorThemeChanged() throws Exception {
    // Mocks
    Event event = mock(Event.class);
    XWikiDocument doc = mock(XWikiDocument.class);
    Object data = new Object();
    EntityReference classReference = new LocalDocumentReference("ColorThemes", "ColorThemeClass");
    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);
    ColorThemeReference colorThemeReference = new DocumentColorThemeReference(documentReference, null);
    when(colorThemeReferenceFactory.createReference(eq(documentReference))).thenReturn(colorThemeReference);
    // Test
    mocker.getComponentUnderTest().onEvent(event, doc, data);
    // Verify
    verify(lessResourcesCache).clearFromColorTheme(colorThemeReference);
    verify(colorThemeCache).clearFromColorTheme(colorThemeReference);
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentColorThemeReference(org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference) ColorThemeReference(org.xwiki.lesscss.internal.colortheme.ColorThemeReference) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentColorThemeReference(org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference) 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) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentReference(org.xwiki.model.reference.DocumentReference) BaseObject(com.xpn.xwiki.objects.BaseObject) Test(org.junit.Test)

Example 2 with DocumentColorThemeReference

use of org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference in project xwiki-platform by xwiki.

the class ColorThemeListenerTest method onEventWhenFlamingoThemeChanged.

@Test
public void onEventWhenFlamingoThemeChanged() throws Exception {
    // Mocks
    Event event = mock(Event.class);
    XWikiDocument doc = mock(XWikiDocument.class);
    Object data = new Object();
    EntityReference classReference = new LocalDocumentReference("FlamingoThemesCode", "ThemeClass");
    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);
    ColorThemeReference colorThemeReference = new DocumentColorThemeReference(documentReference, null);
    when(colorThemeReferenceFactory.createReference(eq(documentReference))).thenReturn(colorThemeReference);
    // Test
    mocker.getComponentUnderTest().onEvent(event, doc, data);
    // Verify
    verify(lessResourcesCache).clearFromColorTheme(colorThemeReference);
    verify(colorThemeCache).clearFromColorTheme(colorThemeReference);
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentColorThemeReference(org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference) ColorThemeReference(org.xwiki.lesscss.internal.colortheme.ColorThemeReference) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) DocumentColorThemeReference(org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference) 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) 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)2 BaseObject (com.xpn.xwiki.objects.BaseObject)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)2 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)2 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)2 ColorThemeReference (org.xwiki.lesscss.internal.colortheme.ColorThemeReference)2 DocumentColorThemeReference (org.xwiki.lesscss.internal.colortheme.DocumentColorThemeReference)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 EntityReference (org.xwiki.model.reference.EntityReference)2 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)2 Event (org.xwiki.observation.event.Event)2