- private static DataTreeCandidateTip addCar(ShardDataTree shardDataTree) throws ExecutionException, InterruptedException {
- return doTransaction(shardDataTree, new DataTreeOperation() {
- @Override
- public void execute(DataTreeModification snapshot) {
- snapshot.merge(CarsModel.BASE_PATH, CarsModel.emptyContainer());
- snapshot.merge(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
- snapshot.write(CarsModel.newCarPath("altima"), CarsModel.newCarEntry("altima", new BigInteger("100")));
- }
+ verifyOnDataTreeChanged(listener, dtc -> {
+ assertEquals("getModificationType", ModificationType.WRITE, dtc.getRootNode().getModificationType());
+ assertEquals("getRootPath", CarsModel.newCarPath("sportage"), dtc.getRootPath());
+ });
+
+ ShardDataTree newDataTree = new ShardDataTree(mockShard, fullSchema, TreeType.OPERATIONAL);
+ addCar(newDataTree, "optima");
+ addCar(newDataTree, "murano");
+
+ shardDataTree.applySnapshot(newDataTree.takeStateSnapshot());
+
+ Map<YangInstanceIdentifier, ModificationType> expChanges = Maps.newHashMap();
+ expChanges.put(CarsModel.newCarPath("optima"), ModificationType.WRITE);
+ expChanges.put(CarsModel.newCarPath("murano"), ModificationType.WRITE);
+ expChanges.put(CarsModel.newCarPath("sportage"), ModificationType.DELETE);
+ verifyOnDataTreeChanged(listener, dtc -> {
+ ModificationType expType = expChanges.remove(dtc.getRootPath());
+ assertNotNull("Got unexpected change for " + dtc.getRootPath(), expType);
+ assertEquals("getModificationType", expType, dtc.getRootNode().getModificationType());