use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method whenTimelinesAreAdjacent.
@Test
public void whenTimelinesAreAdjacent() throws Exception {
final Timeline initialTimeline = mockTimeline(1, 10L);
final Timeline finalTimeline = mockOpenTimeline(2);
mockTimelines(initialTimeline, finalTimeline);
final NakadiCursor initialCursor = NakadiCursor.of(initialTimeline, "0", "0000000000000003");
final NakadiCursor finalCursor = NakadiCursor.of(finalTimeline, "0", "0000000000000001");
final Long distance = service.calculateDistance(initialCursor, finalCursor);
assertThat(distance, equalTo(9L));
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method whenTimelinesAreNotAdjacent.
@Test
public void whenTimelinesAreNotAdjacent() throws Exception {
final Timeline initialTimeline = mockTimeline(1, 10L);
final Timeline intermediaryTimeline = mockTimeline(2, 9L);
final Timeline finalTimeline = mockTimeline(3, 0L);
mockTimelines(initialTimeline, intermediaryTimeline, finalTimeline);
final NakadiCursor initialCursor = NakadiCursor.of(initialTimeline, "0", "0000000000000003");
final NakadiCursor finalCursor = NakadiCursor.of(finalTimeline, "0", "0000000000000001");
assertThat(service.calculateDistance(initialCursor, finalCursor), equalTo(7L + 10L + 2L));
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method shiftCursorToTheRightSameClosedTimeline.
@Test
public void shiftCursorToTheRightSameClosedTimeline() throws Exception {
final Timeline initialTimeline = mockTimeline(0, 10L);
final ShiftedNakadiCursor shiftedCursor = new ShiftedNakadiCursor(initialTimeline, "0", "000000000000000003", 2L);
mockTimelines(initialTimeline);
final NakadiCursor cursor = service.unshiftCursor(shiftedCursor);
assertThat(cursor.getOffset(), equalTo("000000000000000005"));
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class CursorOperationsServiceTest method whenTimelineExpired.
@Test(expected = InvalidCursorOperation.class)
public void whenTimelineExpired() throws Exception {
// order is zero
final Timeline expiredTimeline = timeline;
final Timeline initialTimeline = mockTimeline(1, 10L);
final Timeline finalTimeline = mockTimeline(2, 0L);
mockTimelines(initialTimeline, finalTimeline);
final NakadiCursor initialCursor = NakadiCursor.of(expiredTimeline, "0", "0000000000000001");
final NakadiCursor finalCursor = NakadiCursor.of(expiredTimeline, "2", "0000000000000002");
service.calculateDistance(initialCursor, finalCursor);
}
use of org.zalando.nakadi.domain.NakadiCursor in project nakadi by zalando.
the class SubscriptionValidationServiceTest method mockCursorWithTimeline.
private static NakadiCursor mockCursorWithTimeline() {
final Timeline timeline = mock(Timeline.class);
when(timeline.isDeleted()).thenReturn(false);
final NakadiCursor cursor = mock(NakadiCursor.class);
when(cursor.getTimeline()).thenReturn(timeline);
return cursor;
}
Aggregations