use of org.zalando.nakadi.repository.db.EventTypeCache in project nakadi by zalando.
the class EventStreamTest method setupMocks.
@BeforeClass
public static void setupMocks() {
final TimelineService timelineService = mock(TimelineService.class);
final EventTypeCache eventTypeCache = mock(EventTypeCache.class);
cursorConverter = new CursorConverterImpl(eventTypeCache, timelineService);
writerProvider = mock(EventStreamWriterProvider.class);
}
use of org.zalando.nakadi.repository.db.EventTypeCache in project nakadi by zalando.
the class EventTypeChangeListenerTest method setUp.
@Before
public void setUp() {
final EventTypeCache cache = mock(EventTypeCache.class);
final ArgumentCaptor<Consumer> changeCall = ArgumentCaptor.forClass(Consumer.class);
listener = new EventTypeChangeListener(cache);
verify(cache, times(1)).addInvalidationListener(changeCall.capture());
notificationTrigger = changeCall.getValue();
}
use of org.zalando.nakadi.repository.db.EventTypeCache in project nakadi by zalando.
the class CursorConverterImplTest method testBeginConvertedVersionZero.
@Test
public void testBeginConvertedVersionZero() throws Exception {
final String eventType = "test-et";
final String partition = "2";
final Storage storage = new Storage("", Storage.Type.KAFKA);
final Timeline timeline = mock(Timeline.class);
when(timeline.getStorage()).thenReturn(storage);
final EventTypeCache eventTypeCache = mock(EventTypeCache.class);
final TopicRepository topicRepository = mock(TopicRepository.class);
final TimelineService timelineService = mock(TimelineService.class);
final PartitionStatistics stats = mock(PartitionStatistics.class);
when(timelineService.getActiveTimelinesOrdered(eq(eventType))).thenReturn(Collections.singletonList(timeline));
when(timelineService.getTopicRepository(eq(timeline))).thenReturn(topicRepository);
when(topicRepository.loadPartitionStatistics(eq(timeline), eq(partition))).thenReturn(Optional.of(stats));
final NakadiCursor beforeFirstCursor = NakadiCursor.of(timeline, partition, "000001");
when(stats.getBeforeFirst()).thenReturn(beforeFirstCursor);
final CursorConverter converter = new CursorConverterImpl(eventTypeCache, timelineService);
final NakadiCursor nakadiCursor = converter.convert(eventType, new Cursor(partition, "BEGIN"));
Assert.assertEquals(timeline, nakadiCursor.getTimeline());
Assert.assertEquals(partition, nakadiCursor.getPartition());
Assert.assertEquals("000001", nakadiCursor.getOffset());
}
use of org.zalando.nakadi.repository.db.EventTypeCache in project nakadi by zalando.
the class RepositoriesConfig method eventTypeCache.
@Bean
public EventTypeCache eventTypeCache(final ZooKeeperHolder zooKeeperHolder, @DB final EventTypeRepository eventTypeRepository, @DB final TimelineDbRepository timelineRepository, final TimelineSync timelineSync) {
ValidationStrategy.register(EventBodyMustRespectSchema.NAME, new EventBodyMustRespectSchema(new JsonSchemaEnrichment()));
ValidationStrategy.register(EventMetadataValidationStrategy.NAME, new EventMetadataValidationStrategy());
try {
return new EventTypeCache(eventTypeRepository, timelineRepository, zooKeeperHolder, timelineSync);
} catch (final Exception e) {
throw new IllegalStateException("failed to create event type cache", e);
}
}
use of org.zalando.nakadi.repository.db.EventTypeCache in project nakadi by zalando.
the class PartitionsControllerTest method before.
@Before
public void before() throws InternalNakadiException, NoSuchEventTypeException {
eventTypeRepositoryMock = mock(EventTypeRepository.class);
topicRepositoryMock = mock(TopicRepository.class);
eventTypeCache = mock(EventTypeCache.class);
timelineService = Mockito.mock(TimelineService.class);
cursorOperationsService = Mockito.mock(CursorOperationsService.class);
when(timelineService.getActiveTimelinesOrdered(eq(UNKNOWN_EVENT_TYPE))).thenThrow(NoSuchEventTypeException.class);
when(timelineService.getActiveTimelinesOrdered(eq(TEST_EVENT_TYPE))).thenReturn(Collections.singletonList(TIMELINE));
when(timelineService.getAllTimelinesOrdered(eq(TEST_EVENT_TYPE))).thenReturn(Collections.singletonList(TIMELINE));
when(timelineService.getTopicRepository((Timeline) any())).thenReturn(topicRepositoryMock);
final CursorConverter cursorConverter = new CursorConverterImpl(eventTypeCache, timelineService);
final PartitionsController controller = new PartitionsController(timelineService, cursorConverter, cursorOperationsService, eventTypeRepositoryMock, authorizationValidator);
settings = mock(SecuritySettings.class);
final FeatureToggleService featureToggleService = Mockito.mock(FeatureToggleService.class);
mockMvc = standaloneSetup(controller).setMessageConverters(new StringHttpMessageConverter(), TestUtils.JACKSON_2_HTTP_MESSAGE_CONVERTER).setCustomArgumentResolvers(new ClientResolver(settings, featureToggleService)).setControllerAdvice(new ExceptionHandling()).build();
}
Aggregations