Assert.assertEquals(LedgerRanges.getDefaultInstance(), ranges.getValue());
LedgerRange lastRange = LedgerRange.newBuilder().setLedgerId(1).build();
LedgerRanges.Builder builder = LedgerRanges.newBuilder();
builder.addRanges(lastRange);
LedgerRanges newRanges = builder.build();
// write existed persistence info with null version
tpManager.writeTopicPersistenceInfo(topic, newRanges, Version.NEW,
writeCallback, null);
res = writeCallback.queue.take();
Assert.assertNotNull(res.right());
Assert.assertTrue(res.right() instanceof PubSubException.TopicPersistenceInfoExistsException);
// write existed persistence info with right version
tpManager.writeTopicPersistenceInfo(topic, newRanges, v1,
writeCallback, null);
res = writeCallback.queue.take();
Assert.assertEquals(null, res.right());
Version v2 = res.left();
Assert.assertEquals(Version.Occurred.AFTER, v2.compare(v1));
// read persistence info
tpManager.readTopicPersistenceInfo(topic, readCallback, null);
ranges = readCallback.queue.take().left();
Assert.assertEquals(Version.Occurred.CONCURRENTLY, v2.compare(ranges.getVersion()));
Assert.assertEquals(newRanges, ranges.getValue());
lastRange = LedgerRange.newBuilder().setLedgerId(2).build();
builder = LedgerRanges.newBuilder();
builder.addRanges(lastRange);
LedgerRanges newRanges2 = builder.build();
// write existed persistence info with bad version
tpManager.writeTopicPersistenceInfo(topic, newRanges2, v1,
writeCallback, null);
res = writeCallback.queue.take();