- @Test
- public void testModicationRecovery() throws Exception {
-
- // Set up the InMemorySnapshotStore.
- setupInMemorySnapshotStore();
-
- // Set up the InMemoryJournal.
-
- InMemoryJournal.addEntry(shardID.toString(), 0, DUMMY_DATA);
-
- InMemoryJournal.addEntry(shardID.toString(), 1, new ReplicatedLogImplEntry(0, 1, newModificationPayload(
- new WriteModification(TestModel.OUTER_LIST_PATH,
- ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()))));
-
- final int nListEntries = 16;
- final Set<Integer> listEntryKeys = new HashSet<>();
-
- // Add some ModificationPayload entries
- for(int i = 1; i <= nListEntries; i++) {
- listEntryKeys.add(Integer.valueOf(i));
- final YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
- .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build();
- final Modification mod = new MergeModification(path,
- ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i));
- InMemoryJournal.addEntry(shardID.toString(), i + 1, new ReplicatedLogImplEntry(i, 1,
- newModificationPayload(mod)));
- }
-
- InMemoryJournal.addEntry(shardID.toString(), nListEntries + 2,
- new ApplyJournalEntries(nListEntries));
-
- testRecovery(listEntryKeys);
- }
-
- private static ModificationPayload newModificationPayload(final Modification... mods) throws IOException {
- final MutableCompositeModification compMod = new MutableCompositeModification();
- for(final Modification mod: mods) {
- compMod.addModification(mod);
- }
-
- return new ModificationPayload(compMod);
- }
-