Fix followerDistributedDataStore tear down
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / modification / MergeModificationTest.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.modification;
9
10 import static org.junit.Assert.assertEquals;
11
12 import java.util.Optional;
13 import org.apache.commons.lang3.SerializationUtils;
14 import org.junit.Test;
15 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
16 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
19 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
20
21 @Deprecated(since = "9.0.0", forRemoval = true)
22 public class MergeModificationTest extends AbstractModificationTest {
23     @Test
24     public void testApply() throws Exception {
25         //TODO : Need to write a better test for this
26
27         //Write something into the datastore
28         DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
29         MergeModification writeModification = new MergeModification(TestModel.TEST_PATH,
30                 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
31         writeModification.apply(writeTransaction);
32         commitTransaction(writeTransaction);
33
34         //Check if it's in the datastore
35         assertEquals(Optional.of(TEST_CONTAINER), readData(TestModel.TEST_PATH));
36     }
37
38     @Test
39     public void testSerialization() {
40         MergeModification expected = new MergeModification(TestModel.TEST_PATH, Builders.containerBuilder()
41             .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
42             .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo"))
43             .build());
44
45         MergeModification clone = SerializationUtils.clone(expected);
46         assertEquals("getPath", expected.getPath(), clone.getPath());
47         assertEquals("getData", expected.getData(), clone.getData());
48     }
49 }