use of org.zalando.nakadi.domain.Timeline in project nakadi by zalando.
the class EventTypeCacheTestAT method getMockedTimelines.
private List<Timeline> getMockedTimelines(final String etName) {
final Timeline t1 = new Timeline(etName, 0, new Storage(), "topic", new Date());
final Timeline t2 = new Timeline(etName, 1, new Storage(), "topic", new Date(System.currentTimeMillis() + 200));
t2.setSwitchedAt(new Date(System.currentTimeMillis() + 300));
final Timeline t3 = new Timeline(etName, 2, new Storage(), "topic", new Date(System.currentTimeMillis() + 500));
return ImmutableList.of(t1, t2, t3);
}
use of org.zalando.nakadi.domain.Timeline in project nakadi by zalando.
the class StorageDbRepositoryTest method testDeleteUsedStorage.
@Test(expected = StorageIsUsedException.class)
public void testDeleteUsedStorage() throws Exception {
final String name = randomUUID();
final Storage storage = repository.createStorage(createStorage(name, "exaddress", 8181, "address", "path"));
final EventType eventType = eventTypeDbRepository.saveEventType(TestUtils.buildDefaultEventType());
final Timeline timeline = TimelineDbRepositoryTest.createTimeline(storage, UUID.randomUUID(), 0, "topic", eventType.getName(), new Date(), new Date(), null, null);
timelineDbRepository.createTimeline(timeline);
repository.deleteStorage(storage.getId());
}
use of org.zalando.nakadi.domain.Timeline in project nakadi by zalando.
the class TimelineDbRepositoryTest method testTimelineUpdate.
@Test
public void testTimelineUpdate() {
final Timeline initial = insertTimeline(0);
final Timeline modified = tRepository.getTimeline(initial.getId()).get();
modified.setCreatedAt(new Date());
modified.setCleanedUpAt(new Date());
modified.setSwitchedAt(new Date());
final Timeline.KafkaStoragePosition pos = new Timeline.KafkaStoragePosition();
pos.setOffsets(LongStream.range(0L, 10L).mapToObj(Long::new).collect(Collectors.toList()));
modified.setLatestPosition(pos);
tRepository.updateTimelime(modified);
final Timeline result = tRepository.getTimeline(modified.getId()).get();
Assert.assertEquals(modified, result);
Assert.assertNotEquals(initial, result);
}
use of org.zalando.nakadi.domain.Timeline in project nakadi by zalando.
the class TimelineDbRepositoryTest method testTimelineDeleted.
@Test
public void testTimelineDeleted() {
final Timeline t1 = insertTimeline(1);
Assert.assertEquals(1, tRepository.listTimelinesOrdered(testEt.getName()).size());
tRepository.deleteTimeline(t1.getId());
Assert.assertEquals(0, tRepository.listTimelinesOrdered(testEt.getName()).size());
}
use of org.zalando.nakadi.domain.Timeline in project nakadi by zalando.
the class KafkaTopicRepositoryTest method canLoadPartitionEndStatistics.
@Test
public void canLoadPartitionEndStatistics() throws Exception {
final Timeline t1 = mock(Timeline.class);
when(t1.getTopic()).thenReturn(MY_TOPIC);
final Timeline t2 = mock(Timeline.class);
when(t2.getTopic()).thenReturn(ANOTHER_TOPIC);
final ImmutableList<Timeline> timelines = ImmutableList.of(t1, t2);
final List<PartitionEndStatistics> stats = kafkaTopicRepository.loadTopicEndStatistics(timelines);
final Set<PartitionEndStatistics> expected = PARTITIONS.stream().map(p -> {
final Timeline timeline = p.topic.equals(MY_TOPIC) ? t1 : t2;
return new KafkaPartitionEndStatistics(timeline, p.partition, p.latestOffset - 1);
}).collect(Collectors.toSet());
assertThat(newHashSet(stats), equalTo(expected));
}
Aggregations