use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeCacheTestAT method onCreatedAddNewChildrenZNode.
@Test
public void onCreatedAddNewChildrenZNode() throws Exception {
final EventTypeCache etc = new EventTypeCache(eventTypeRepository, timelineRepository, client, timelineSync);
final EventType et = buildDefaultEventType();
etc.created(et.getName());
assertNotNull(client.get().checkExists().forPath("/nakadi/event_types/" + et.getName()));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeCacheTestAT method testGetTimelines.
@Test
public void testGetTimelines() throws Exception {
final EventTypeCache etc = new RepositoriesConfig().eventTypeCache(client, eventTypeRepository, timelineRepository, timelineSync);
final EventType et = buildDefaultEventType();
Mockito.when(timelineRepository.listTimelinesOrdered(et.getName())).thenReturn(getMockedTimelines(et.getName()));
Mockito.doReturn(et).when(eventTypeRepository).findByName(et.getName());
final List<Timeline> timelines = etc.getTimelinesOrdered(et.getName());
Assert.assertEquals(3, timelines.size());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeCacheTestAT method invalidateCacheOnUpdate.
@SuppressWarnings("unchecked")
@Test
public void invalidateCacheOnUpdate() throws Exception {
final EventTypeCache etc = new RepositoriesConfig().eventTypeCache(client, eventTypeRepository, timelineRepository, timelineSync);
final EventType et = buildDefaultEventType();
Mockito.doReturn(et).when(eventTypeRepository).findByName(et.getName());
etc.created(et.getName());
etc.getEventType(et.getName());
etc.updated(et.getName());
executeWithRetry(() -> {
try {
etc.getEventType(et.getName());
verify(eventTypeRepository, times(2)).findByName(et.getName());
} catch (final Exception e) {
fail();
}
}, new RetryForSpecifiedTimeStrategy<Void>(5000).withExceptionsThatForceRetry(AssertionError.class).withWaitBetweenEachTry(500));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeCacheTestAT method whenUpdatedSetChildrenZNodeValue.
@Test
public void whenUpdatedSetChildrenZNodeValue() throws Exception {
final EventTypeCache etc = new EventTypeCache(eventTypeRepository, timelineRepository, client, timelineSync);
final EventType et = buildDefaultEventType();
client.get().create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath("/nakadi/event_types/" + et.getName(), "some-value".getBytes());
etc.updated(et.getName());
final byte[] data = client.get().getData().forPath("/nakadi/event_types/" + et.getName());
assertThat(data, equalTo(new byte[0]));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeDbRepositoryTest method whenListExistingEventTypesAreListed.
@Test
public void whenListExistingEventTypesAreListed() throws NakadiException {
final EventType eventType1 = buildDefaultEventType();
final EventType eventType2 = buildDefaultEventType();
repository.saveEventType(eventType1);
repository.saveEventType(eventType2);
final List<EventType> eventTypes = repository.list().stream().filter(et -> et.getName() != null).filter(et -> et.getName().equals(eventType1.getName()) || et.getName().equals(eventType2.getName())).collect(Collectors.toList());
assertThat(eventTypes, hasSize(2));
}
Aggregations