X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmodification%2FMergeModificationTest.java;h=5d2021167b52564c76a636fc29dc8c94e2d80e66;hb=7e19c2f4d2695cc4d077a1f5882089d8af923696;hp=9af3439ae196d95ca55148465d02b7beb8b9e5a6;hpb=e5baddddcf298e6569aff18e5c4514492980ad9c;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java index 9af3439ae1..5d2021167b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java @@ -7,22 +7,38 @@ import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class MergeModificationTest extends AbstractModificationTest{ - @Test - public void testApply() throws Exception { - //TODO : Need to write a better test for this + @Test + public void testApply() throws Exception { + //TODO : Need to write a better test for this - //Write something into the datastore - DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); - MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()); - writeModification.apply(writeTransaction); - commitTransaction(writeTransaction); + //Write something into the datastore + DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); + MergeModification writeModification = new MergeModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()); + writeModification.apply(writeTransaction); + commitTransaction(writeTransaction); - //Check if it's in the datastore - Optional> data = readData(TestModel.TEST_PATH); - Assert.assertTrue(data.isPresent()); + //Check if it's in the datastore + Optional> data = readData(TestModel.TEST_PATH); + Assert.assertTrue(data.isPresent()); - } + } + + @Test + public void testSerialization() { + SchemaContext schemaContext = TestModel.createTestContext(); + NormalizedNode node = ImmutableNodes.containerNode(TestModel.TEST_QNAME); + MergeModification mergeModification = new MergeModification(TestModel.TEST_PATH, + node, schemaContext); + + Object serialized = mergeModification.toSerializable(); + + MergeModification newModification = MergeModification.fromSerializable(serialized, schemaContext); + + Assert.assertEquals("getPath", TestModel.TEST_PATH, newModification.getPath()); + Assert.assertEquals("getData", node, newModification.getData()); + } }