Search in sources :

Example 1 with EventType

use of tech.pegasys.teku.api.response.v1.EventType in project teku by ConsenSys.

the class EventSubscriberTest method shouldSubscribeToMultipleEventsSuccessfully.

@Test
void shouldSubscribeToMultipleEventsSuccessfully() throws IOException {
    EventSubscriber eventSubscriber = new EventSubscriber(allEventTypes.stream().map(EventType::name).collect(Collectors.toList()), sseClient, onCloseCallback, asyncRunner, MAX_PENDING_EVENTS);
    for (EventType eventType : allEventTypes) {
        eventSubscriber.onEvent(eventType, event("test"));
    }
    assertThat(asyncRunner.countDelayedActions()).isEqualTo(2);
    asyncRunner.executeQueuedActions();
    assertThat(outputStream.countEvents()).isEqualTo(allEventTypes.size());
    assertThat(outputStream.countComments()).isEqualTo(1);
}
Also used : EventType(tech.pegasys.teku.api.response.v1.EventType) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with EventType

use of tech.pegasys.teku.api.response.v1.EventType in project teku by ConsenSys.

the class EventSubscriberTest method shouldNotSendEventsIfNotSubscribed.

@ParameterizedTest
@EnumSource(EventType.class)
void shouldNotSendEventsIfNotSubscribed(final EventType eventType) throws Exception {
    EventSubscriber subscriber = new EventSubscriber(List.of(eventType.name()), sseClient, onCloseCallback, asyncRunner, MAX_PENDING_EVENTS);
    for (EventType val : allEventTypes) {
        if (val.compareTo(eventType) != 0) {
            subscriber.onEvent(val, event("test"));
        }
    }
    assertThat(asyncRunner.countDelayedActions()).isEqualTo(1);
    asyncRunner.executeQueuedActions();
    assertThat(outputStream.countEvents()).isEqualTo(0);
    assertThat(outputStream.countComments()).isEqualTo(1);
}
Also used : EventType(tech.pegasys.teku.api.response.v1.EventType) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EventType (tech.pegasys.teku.api.response.v1.EventType)2 Test (org.junit.jupiter.api.Test)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1