@Test public void onEventWhenColorThemeChanged() throws Exception { 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); mocker.getComponentUnderTest().onEvent(event, doc, data); verify(lessResourcesCache).clearFromColorTheme(colorThemeReference); verify(colorThemeCache).clearFromColorTheme(colorThemeReference); }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; List<BaseObject> flamingoThemeObjects = document.getXObjects(FLAMINGO_THEME_CLASS); if (flamingoThemeObjects != null && !flamingoThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } List<BaseObject> colorThemeObjects = document.getXObjects(COLOR_THEME_CLASS); if (colorThemeObjects != null && !colorThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } }
ColorThemeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; List<BaseObject> flamingoThemeObjects = document.getXObjects(FLAMINGO_THEME_CLASS); if (flamingoThemeObjects != null && !flamingoThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } List<BaseObject> colorThemeObjects = document.getXObjects(COLOR_THEME_CLASS); if (colorThemeObjects != null && !colorThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } } }
ColorThemeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; List<BaseObject> flamingoThemeObjects = document.getXObjects(FLAMINGO_THEME_CLASS); if (flamingoThemeObjects != null && !flamingoThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } List<BaseObject> colorThemeObjects = document.getXObjects(COLOR_THEME_CLASS); if (colorThemeObjects != null && !colorThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } }  }
ColorThemeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; List<BaseObject> flamingoThemeObjects = document.getXObjects(FLAMINGO_THEME_CLASS); if (flamingoThemeObjects != null && !flamingoThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } List<BaseObject> colorThemeObjects = document.getXObjects(COLOR_THEME_CLASS); if (colorThemeObjects != null && !colorThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } }  @Override String getName(); @Override List<Event> getEvents(); @Override void onEvent(Event event, Object source, Object data); }
ColorThemeListener implements EventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiDocument document = (XWikiDocument) source; List<BaseObject> flamingoThemeObjects = document.getXObjects(FLAMINGO_THEME_CLASS); if (flamingoThemeObjects != null && !flamingoThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } List<BaseObject> colorThemeObjects = document.getXObjects(COLOR_THEME_CLASS); if (colorThemeObjects != null && !colorThemeObjects.isEmpty()) { clearCacheFromColorTheme(document); return; } }  @Override String getName(); @Override List<Event> getEvents(); @Override void onEvent(Event event, Object source, Object data);  }