use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class DefaultDocumentCacheTest method testEventBasedCleanup.
@Test
public void testEventBasedCleanup() throws Exception {
this.cache.set("data", this.document.getDocumentReference());
this.cache.set("data", this.document.getDocumentReference(), "ext1", "ext2");
ObservationManager observationManager = getComponentManager().getInstance(ObservationManager.class);
observationManager.notify(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, getContext());
Assert.assertNull(this.cache.get(this.document.getDocumentReference()));
Assert.assertNull(this.cache.get(this.document.getDocumentReference(), "ext1", "ext2"));
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class DefaultRenderingCacheTest method testGetSetRenderedContent.
@Test
public void testGetSetRenderedContent() throws Exception {
MockConfigurationSource source = getConfigurationSource();
source.setProperty("core.renderingcache.documents", Collections.singletonList(this.document.getPrefixedFullName()));
this.renderingCache.setRenderedContent(this.document.getDocumentReference(), "source", "renderedContent", getContext());
Assert.assertEquals("renderedContent", this.renderingCache.getRenderedContent(this.document.getDocumentReference(), "source", getContext()));
this.parameters.put("param", new String[] { "value1", "value2" });
Assert.assertNull(this.renderingCache.getRenderedContent(this.document.getDocumentReference(), "source", getContext()));
this.parameters.remove("param");
Assert.assertEquals("renderedContent", this.renderingCache.getRenderedContent(this.document.getDocumentReference(), "source", getContext()));
ObservationManager observationManager = getComponentManager().getInstance(ObservationManager.class);
observationManager.notify(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, getContext());
Assert.assertNull(this.renderingCache.getRenderedContent(this.document.getDocumentReference(), "source", getContext()));
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectPropertyModified.
@Test
public void testModifiedDocumentXObjectPropertyModified() throws ComponentLookupException {
this.xobject.setStringValue("updatedproperty", "propertyvalue");
BaseObject xobjectModified = this.xobject.clone();
xobjectModified.setStringValue("updatedproperty", "propertyvaluemodified");
this.document.addXObject(this.xobject);
this.documentOrigin.addXObject(xobjectModified);
final Event event = new XObjectPropertyUpdatedEvent(this.xobject.getField("updatedproperty").getReference());
this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
// Make sure the listener generated a xobject property updated event
verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext()));
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class XObjectEventGeneratorListenerTest method testModifiedDocumentXObjectAdded.
@Test
public void testModifiedDocumentXObjectAdded() throws ComponentLookupException {
this.document.addXObject(this.xobject);
final Event event = new XObjectAddedEvent(this.xobject.getReference());
this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(this.document.getDocumentReference()), this.document, this.oldcore.getXWikiContext());
// Make sure the listener generated a xobject added event
verify(this.mockObservation).notify(eq(event), same(this.document), same(this.oldcore.getXWikiContext()));
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class SolrIndexEventListenerTest method onDocumentTranslationUpdated.
@Test
public void onDocumentTranslationUpdated() throws Exception {
XWikiDocument translation = mock(XWikiDocument.class);
DocumentReference translationReference = new DocumentReference("wiki", "Path", "Page", Locale.FRENCH);
when(translation.getDocumentReferenceWithLocale()).thenReturn(translationReference);
this.mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(), translation, null);
verify(this.indexer).index(translationReference, false);
verify(this.indexer, times(1)).index(any(EntityReference.class), any(Boolean.class));
}
Aggregations