1 package org.opendaylight.controller.cluster.datastore.modification;
3 import com.google.common.base.Optional;
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;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertNotNull;
14 public class MutableCompositeModificationTest extends AbstractModificationTest {
17 public void testApply() throws Exception {
19 MutableCompositeModification compositeModification = new MutableCompositeModification();
20 compositeModification.addModification(new WriteModification(TestModel.TEST_PATH,
21 ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()));
23 DOMStoreReadWriteTransaction transaction = store.newReadWriteTransaction();
24 compositeModification.apply(transaction);
25 commitTransaction(transaction);
27 Optional<NormalizedNode<?, ?>> data = readData(TestModel.TEST_PATH);
29 assertNotNull(data.get());
30 assertEquals(TestModel.TEST_QNAME, data.get().getNodeType());
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 Object one = compositeModification.toSerializable();
39 try{Thread.sleep(10);}catch(Exception err){}
40 Object two = compositeModification.toSerializable();
41 assertNotEquals(one,two);