use of org.xwiki.eventstream.UntypedRecordableEventDescriptor 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.eventstream.UntypedRecordableEventDescriptor 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());
}
Aggregations