use of org.apache.kafka.controller.SnapshotGenerator.Section in project kafka by apache.
the class SnapshotGeneratorTest method testGenerateBatches.
@Test
public void testGenerateBatches() throws Exception {
SnapshotWriter<ApiMessageAndVersion> writer = createSnapshotWriter(123, 0);
List<Section> sections = Arrays.asList(new Section("replication", Arrays.asList(BATCHES.get(0), BATCHES.get(1), BATCHES.get(2)).iterator()), new Section("configuration", Arrays.asList(BATCHES.get(3), BATCHES.get(4)).iterator()));
SnapshotGenerator generator = new SnapshotGenerator(new LogContext(), writer, 2, sections);
assertFalse(writer.isFrozen());
assertEquals(123L, generator.lastContainedLogOffset());
assertEquals(writer, generator.writer());
assertEquals(OptionalLong.of(0L), generator.generateBatches());
assertEquals(OptionalLong.of(0L), generator.generateBatches());
assertFalse(writer.isFrozen());
assertEquals(OptionalLong.empty(), generator.generateBatches());
assertTrue(writer.isFrozen());
}
Aggregations