use of com.github.ambry.store.MessageStoreHardDelete in project ambry by linkedin.
the class BlobStoreHardDeleteTest method blobStoreHardDeleteTestUtil.
private void blobStoreHardDeleteTestUtil(short[] blobVersions, BlobType[] blobTypes) throws MessageFormatException, IOException {
MessageStoreHardDelete hardDelete = new BlobStoreHardDelete();
StoreKeyFactory keyFactory = new MockIdFactory();
// create log and write to it
ReadImp readImp = new ReadImp();
ArrayList<Long> msgOffsets = readImp.initialize(blobVersions, blobTypes);
Iterator<HardDeleteInfo> iter = hardDelete.getHardDeleteMessages(readImp.getMessageReadSet(), keyFactory, readImp.getRecoveryInfoList());
List<HardDeleteInfo> hardDeletedList = new ArrayList<HardDeleteInfo>();
while (iter.hasNext()) {
hardDeletedList.add(iter.next());
}
// msg1
HardDeleteInfo hardDeleteInfo = hardDeletedList.get(0);
Assert.assertNotNull(hardDeleteInfo);
HardDeleteRecoveryMetadata hardDeleteRecoveryMetadata = new HardDeleteRecoveryMetadata(hardDeleteInfo.getRecoveryInfo(), keyFactory);
Assert.assertEquals(blobTypes[1], hardDeleteRecoveryMetadata.getBlobType());
Assert.assertEquals(blobVersions[1], hardDeleteRecoveryMetadata.getBlobRecordVersion());
// msg2
hardDeleteInfo = hardDeletedList.get(1);
Assert.assertNotNull(hardDeleteInfo);
hardDeleteRecoveryMetadata = new HardDeleteRecoveryMetadata(hardDeleteInfo.getRecoveryInfo(), keyFactory);
Assert.assertEquals(blobTypes[2], hardDeleteRecoveryMetadata.getBlobType());
Assert.assertEquals(blobVersions[2], hardDeleteRecoveryMetadata.getBlobRecordVersion());
// msg5
hardDeleteInfo = hardDeletedList.get(2);
Assert.assertNotNull(hardDeleteInfo);
hardDeleteRecoveryMetadata = new HardDeleteRecoveryMetadata(hardDeleteInfo.getRecoveryInfo(), keyFactory);
Assert.assertEquals(blobTypes[3], hardDeleteRecoveryMetadata.getBlobType());
Assert.assertEquals(blobVersions[3], hardDeleteRecoveryMetadata.getBlobRecordVersion());
// msg6 - NULL.
Assert.assertNull(hardDeletedList.get(3));
}
Aggregations