- public void testEverySerializedCompositeModificationObjectMustBeDifferent(){
- MutableCompositeModification compositeModification = new MutableCompositeModification();
- compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
- ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
+ public void testSerializationModern() {
+ YangInstanceIdentifier writePath = TestModel.TEST_PATH;
+ ContainerNode writeData = Builders.containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo"))
+ .build();
+
+ 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());