X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fmodification%2FWriteModificationTest.java;h=3a82fffccb16ffe9e02b3e85c2106213e749dce1;hp=e206bf8196e034d0fdd4d3cb77207de41380e97e;hb=5adfd98dac66cab656090d1b51324b4d09573bd9;hpb=3c0667dedcd089624c4de1fdf39f9c971bdce209 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java index e206bf8196..3a82fffccb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java @@ -7,20 +7,36 @@ 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 WriteModificationTest extends AbstractModificationTest{ - @Test - public void testApply() throws Exception { - //Write something into the datastore - DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); - WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - writeModification.apply(writeTransaction); - commitTransaction(writeTransaction); + @Test + public void testApply() throws Exception { + //Write something into the datastore + DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction(); + WriteModification writeModification = new WriteModification(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()); + } - } -} \ No newline at end of file + @Test + public void testSerialization() { + SchemaContext schemaContext = TestModel.createTestContext(); + NormalizedNode node = ImmutableNodes.containerNode(TestModel.TEST_QNAME); + WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, + node, schemaContext); + + Object serialized = writeModification.toSerializable(); + + WriteModification newModification = WriteModification.fromSerializable(serialized, schemaContext); + + Assert.assertEquals("getPath", TestModel.TEST_PATH, newModification.getPath()); + Assert.assertEquals("getData", node, newModification.getData()); + } +}