use of io.pravega.client.stream.impl.ReaderGroupState.UpdateDistanceToTail.UpdateDistanceToTailSerializer in project pravega by pravega.
the class SerializationTest method testUpdateDistanceToTail.
@Test
@SuppressWarnings("unchecked")
public void testUpdateDistanceToTail() throws Exception {
UpdateDistanceToTailSerializer serializer = new UpdateDistanceToTail.UpdateDistanceToTailSerializer();
UpdateDistanceToTail update = new UpdateDistanceToTail(createString(), r.nextLong(), createSegmentRangeMap());
UpdateDistanceToTail deserialized = serializer.deserialize(serializer.serialize(update));
assertEquals(deserialized, update);
UpdateDistanceToTailSerializer oldSerializer = new UpdateDistanceToTailSerializer() {
@Override
protected void declareVersions() {
version(0).revision(0, this::write00, this::read00);
}
};
UpdateDistanceToTail oldStyleUpdate = serializer.deserialize(oldSerializer.serialize(update));
assertEquals(update.getReaderId(), oldStyleUpdate.getReaderId());
assertEquals(update.getDistanceToTail(), oldStyleUpdate.getDistanceToTail());
assertEquals(null, oldStyleUpdate.getLastReadPositions());
// Change the state to reflect the update
val segmentToOffsets = ImmutableMap.of(new SegmentWithRange(new Segment("scope", "stream", 0), 0.0, 1.0), 0L);
ReaderGroupState state = new ReaderGroupState("_RGTest", mock(Revision.class), mock(ReaderGroupConfig.class), segmentToOffsets, mock(Map.class), false);
// ensure no exceptions are thrown.
oldStyleUpdate.update(state);
}
Aggregations