- MutableCompositeModification compositeModification = new MutableCompositeModification();
- for(int i = 0; i < 1000; i++) {
- compositeModification.addModification(new WriteModification(writePath, writeData));
- }
-
- Stopwatch sw = new Stopwatch();
- sw.start();
- for(int i = 0; i < 1000; i++) {
- new ModificationPayload(compositeModification);
- }
-
- sw.stop();
- System.out.println("Elapsed: "+sw);
-
- ModificationPayload p = new ModificationPayload(compositeModification);
- sw.start();
- for(int i = 0; i < 1000; i++) {
- p.getModification();
- }
-
- sw.stop();
- System.out.println("Elapsed: "+sw);
+ YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH;
+ ContainerNode mergeData = Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME))
+ .build();
+
+ YangInstanceIdentifier deletePath = TestModel.TEST_PATH;
+
+ MutableCompositeModification compositeModification =
+ new MutableCompositeModification();
+ compositeModification.addModification(new WriteModification(writePath, writeData));
+ compositeModification.addModification(new MergeModification(mergePath, mergeData));
+ compositeModification.addModification(new DeleteModification(deletePath));
+
+ final byte[] bytes = SerializationUtils.serialize(compositeModification);
+ assertEquals(360, bytes.length);
+ MutableCompositeModification clone = (MutableCompositeModification) SerializationUtils.deserialize(bytes);
+
+ assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, clone.getVersion());
+
+ assertEquals("getModifications size", 3, clone.getModifications().size());
+
+ WriteModification write = (WriteModification)clone.getModifications().get(0);
+ assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, write.getVersion());
+ assertEquals("getPath", writePath, write.getPath());
+ assertEquals("getData", writeData, write.getData());
+
+ MergeModification merge = (MergeModification)clone.getModifications().get(1);
+ assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, merge.getVersion());
+ assertEquals("getPath", mergePath, merge.getPath());
+ assertEquals("getData", mergeData, merge.getData());
+
+ DeleteModification delete = (DeleteModification)clone.getModifications().get(2);
+ assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, delete.getVersion());
+ assertEquals("getPath", deletePath, delete.getPath());