Merge "BUG 1623 - Clustering : Parsing Error thrown on startup"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / modification / MutableCompositeModificationTest.java
1 package org.opendaylight.controller.cluster.datastore.modification;
2
3 import com.google.common.base.Optional;
4 import org.junit.Test;
5 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
6 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
7 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
8 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertNotNull;
13
14 public class MutableCompositeModificationTest extends AbstractModificationTest {
15
16     @Test
17     public void testApply() throws Exception {
18
19         MutableCompositeModification compositeModification = new MutableCompositeModification();
20         compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
21             ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
22
23         DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction();
24         compositeModification.apply(transaction);
25         commitTransaction(transaction);
26
27         Optional<NormalizedNode<?, ?>> data = readData(TestModel.TEST_PATH);
28
29         assertNotNull(data.get());
30         assertEquals(TestModel.TEST_QNAME, data.get().getNodeType());
31     }
32
33     @Test
34     public void testEverySerializedCompositeModificationObjectMustBeDifferent(){
35         MutableCompositeModification compositeModification = new MutableCompositeModification();
36         compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
37             ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
38
39         assertNotEquals(compositeModification.toSerializable(), compositeModification.toSerializable());
40
41     }
42 }