Search in sources :

Example 1 with RepositoriesConfig

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());
}
Also used : RepositoriesConfig(org.zalando.nakadi.config.RepositoriesConfig) Timeline(org.zalando.nakadi.domain.Timeline) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) Test(org.junit.Test)

Example 2 with RepositoriesConfig

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));
}
Also used : RepositoriesConfig(org.zalando.nakadi.config.RepositoriesConfig) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 3 with RepositoriesConfig

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));
}
Also used : RepositoriesConfig(org.zalando.nakadi.config.RepositoriesConfig) TestUtils.buildDefaultEventType(org.zalando.nakadi.utils.TestUtils.buildDefaultEventType) EventType(org.zalando.nakadi.domain.EventType) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 RepositoriesConfig (org.zalando.nakadi.config.RepositoriesConfig)3 EventType (org.zalando.nakadi.domain.EventType)3 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)3 TimeoutException (java.util.concurrent.TimeoutException)2 Timeline (org.zalando.nakadi.domain.Timeline)1