use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class UntypedEventListenerTest method onEventWithBlankValidationAndBlankTarget.
@Test
public void onEventWithBlankValidationAndBlankTarget() throws Exception {
// Mocks
mockDescriptor();
// Test
mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(), mock(Object.class), null);
// Verify
verify(this.observationManager, times(1)).notify(any(DefaultUntypedRecordableEvent.class), any(), any());
assertNotNull(answer.getSentEvent());
assertTrue(answer.getSentEvent().getTarget().isEmpty());
assertEquals("myCustomEvent", answer.getSentEvent().getEventType());
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class UntypedEventListenerTest method onEventWithIncorrectValidation.
@Test
public void onEventWithIncorrectValidation() throws Exception {
// Mocks
UntypedRecordableEventDescriptor descriptor = mockDescriptor();
when(descriptor.getValidationExpression()).thenReturn("someVelocityCode");
when(scriptContext.getAttribute("xreturn")).thenReturn(false);
// Test
mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(), mock(Object.class), null);
// Verify
verify(this.observationManager, never()).notify(any(), any(), any());
assertNull(answer.getSentEvent());
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class UntypedEventListenerTest method onEventWithCorrectValidation.
@Test
public void onEventWithCorrectValidation() throws Exception {
// Mocks
UntypedRecordableEventDescriptor descriptor = mockDescriptor();
when(descriptor.getValidationExpression()).thenReturn("someVelocityCode");
when(scriptContext.getAttribute("xreturn")).thenReturn(true);
// Test
Object source = mock(Object.class);
mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(), source, null);
// Verify
verify(this.observationManager, times(1)).notify(any(DefaultUntypedRecordableEvent.class), any(), any());
assertNotNull(answer.getSentEvent());
assertEquals("myCustomEvent", answer.getSentEvent().getEventType());
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class UntypedEventListenerTest method onEventWithoutXObject.
@Test
public void onEventWithoutXObject() throws Exception {
// Mocks
mockDescriptor();
// Same than onEventWithBlankValidationAndBlankTarget() but with no XObject
when(modelBridge.checkXObjectPresence(any(), any())).thenReturn(false);
// Test
Object source = mock(Object.class);
mocker.getComponentUnderTest().onEvent(new DocumentUpdatedEvent(), source, null);
// Verify
verify(this.observationManager, never()).notify(any(), any(), any());
assertNull(answer.getSentEvent());
}
use of org.xwiki.bridge.event.DocumentUpdatedEvent in project xwiki-platform by xwiki.
the class LegacyNotificationDispatcher method getEvents.
@Override
public List<Event> getEvents() {
return new ArrayList<Event>() {
{
add(new DocumentDeletedEvent());
add(new DocumentCreatedEvent());
add(new DocumentUpdatedEvent());
add(new DocumentDeletingEvent());
add(new DocumentCreatingEvent());
add(new DocumentUpdatingEvent());
add(new ActionExecutedEvent());
add(new ActionExecutingEvent());
}
};
}
Aggregations