Search in sources :

Example 1 with FailingSubscriber

use of io.spine.server.event.given.EventSubscriberTestEnv.FailingSubscriber in project core-java by SpineEventEngine.

the class EventSubscriberShould method dispatch_event.

@Test
public void dispatch_event() {
    final EventEnvelope eventEnvelope = createEvent(true);
    final Set<String> dispatchingResult = subscriber.dispatch(eventEnvelope);
    final FailingSubscriber sub = (FailingSubscriber) this.subscriber;
    assertTrue(sub.isMethodCalled());
    assertEquals(1, dispatchingResult.size());
    assertNull(sub.getLastException());
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) FailingSubscriber(io.spine.server.event.given.EventSubscriberTestEnv.FailingSubscriber) Test(org.junit.Test)

Example 2 with FailingSubscriber

use of io.spine.server.event.given.EventSubscriberTestEnv.FailingSubscriber in project core-java by SpineEventEngine.

the class EventSubscriberShould method catch_exceptions_caused_by_methods.

@Test
public void catch_exceptions_caused_by_methods() {
    // Create event which should fail.
    final EventEnvelope eventEnvelope = createEvent(false);
    final Set<String> dispatchingResult = subscriber.dispatch(eventEnvelope);
    final FailingSubscriber sub = (FailingSubscriber) this.subscriber;
    assertTrue(sub.isMethodCalled());
    assertEquals(0, dispatchingResult.size());
    assertEquals(eventEnvelope, sub.getLastErrorEnvelope());
    assertNotNull(sub.getLastException());
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) FailingSubscriber(io.spine.server.event.given.EventSubscriberTestEnv.FailingSubscriber) Test(org.junit.Test)

Aggregations

EventEnvelope (io.spine.core.EventEnvelope)2 FailingSubscriber (io.spine.server.event.given.EventSubscriberTestEnv.FailingSubscriber)2 Test (org.junit.Test)2