use of org.zalando.nakadi.config.RepositoriesConfig 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.config.RepositoriesConfig 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.config.RepositoriesConfig in project nakadi by zalando.
the class EventTypeCacheTestAT method invalidateCacheOnTimelineChange.
@Test
public void invalidateCacheOnTimelineChange() throws Exception {
final TestTimelineSync timelineSync = new TestTimelineSync();
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());
etc.created(et.getName());
timelineSync.invokeListeners();
executeWithRetry(() -> {
try {
etc.getTimelinesOrdered(et.getName());
verify(timelineRepository, times(1)).listTimelinesOrdered(et.getName());
} catch (final Exception e) {
fail();
}
}, new RetryForSpecifiedTimeStrategy<Void>(5000).withExceptionsThatForceRetry(AssertionError.class).withWaitBetweenEachTry(500));
}
Aggregations