use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class VersionOneConverterTest method testCorrectParse.
@Test
public void testCorrectParse() throws Exception {
final Cursor cursor = new Cursor("1", "001-0010-012345");
final String eventTypeName = "my_et";
final Timeline firstTimeline = mock(Timeline.class);
when(firstTimeline.getStorage()).thenReturn(new Storage("default", Storage.Type.KAFKA));
when(firstTimeline.getOrder()).thenReturn(16);
when(eventTypeCache.getTimelinesOrdered(eq(eventTypeName))).thenReturn(Collections.singletonList(firstTimeline));
final NakadiCursor nakadiCursor = converter.convert(eventTypeName, cursor);
Assert.assertEquals(firstTimeline, nakadiCursor.getTimeline());
Assert.assertEquals("1", nakadiCursor.getPartition());
Assert.assertEquals("012345", nakadiCursor.getOffset());
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class VersionOneConverterTest method testFormatOffset.
@Test
public void testFormatOffset() {
final Timeline timeline = mock(Timeline.class);
when(timeline.getOrder()).thenReturn(15);
when(timeline.getStorage()).thenReturn(new Storage("", Storage.Type.KAFKA));
final NakadiCursor cursor = NakadiCursor.of(timeline, "x", "012345");
Assert.assertEquals("001-000f-012345", new VersionOneConverter(null).formatOffset(cursor));
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method whenCursorsAreInTheSameTimeline.
@Test
public void whenCursorsAreInTheSameTimeline() throws Exception {
final NakadiCursor initialCursor = NakadiCursor.of(timeline, "0", "0000000000000001");
final NakadiCursor finalCursor = NakadiCursor.of(timeline, "0", "0000000000000002");
final Long distance = service.calculateDistance(initialCursor, finalCursor);
assertThat(distance, equalTo(1L));
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method shiftCursorRightToNextTimeline.
@Test
public void shiftCursorRightToNextTimeline() throws Exception {
final Timeline initialTimeline = mockTimeline(1, 10L);
final Timeline nextTimeline = mockTimeline(2, 3L);
final ShiftedNakadiCursor shiftedCursor = new ShiftedNakadiCursor(initialTimeline, "0", "000000000000000003", 9L);
mockTimelines(initialTimeline, nextTimeline);
final NakadiCursor cursor = service.unshiftCursor(shiftedCursor);
assertThat(cursor.getTimeline().getOrder(), equalTo(2));
assertThat(cursor.getOffset(), equalTo("000000000000000001"));
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method whenPartitionsDontMatch.
@Test
public void whenPartitionsDontMatch() throws Exception {
final NakadiCursor initialCursor = NakadiCursor.of(timeline, "1", "0000000000000001");
final NakadiCursor finalCursor = NakadiCursor.of(timeline, "0", "0000000000000002");
expectException(initialCursor, finalCursor, CURSORS_WITH_DIFFERENT_PARTITION);
}
Aggregations