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%2FMutableCompositeModificationTest.java;h=03aaace0e354543f63d8e9f7ed5d74f998fc142c;hp=7a21c8cdc5eea9ea208c651286423c63b107a13b;hb=35f74293edf98402e2b622e060185f7874d10857;hpb=c222e37f2a0f0f3f6266242fbea2d3b018f4e6e3 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java index 7a21c8cdc5..03aaace0e3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java @@ -1,28 +1,42 @@ package org.opendaylight.controller.cluster.datastore.modification; import com.google.common.base.Optional; -import junit.framework.Assert; import org.junit.Test; 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + public class MutableCompositeModificationTest extends AbstractModificationTest { - @Test - public void testApply() throws Exception { + @Test + public void testApply() throws Exception { + + MutableCompositeModification compositeModification = new MutableCompositeModification(); + compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, + ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); + + DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction(); + compositeModification.apply(transaction); + commitTransaction(transaction); + + Optional> data = readData(TestModel.TEST_PATH); - MutableCompositeModification compositeModification = new MutableCompositeModification(); - compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); + assertNotNull(data.get()); + assertEquals(TestModel.TEST_QNAME, data.get().getNodeType()); + } - DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction(); - compositeModification.apply(transaction); - commitTransaction(transaction); + @Test + public void testEverySerializedCompositeModificationObjectMustBeDifferent(){ + MutableCompositeModification compositeModification = new MutableCompositeModification(); + compositeModification.addModification(new WriteModification(TestModel.TEST_PATH, + ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext())); - Optional> data = readData(TestModel.TEST_PATH); + assertNotEquals(compositeModification.toSerializable(), compositeModification.toSerializable()); - Assert.assertNotNull(data.get()); - Assert.assertEquals(TestModel.TEST_QNAME, data.get().getNodeType()); - } + } }