Bug 8163: Use MT DTCL executor in AbstractConcurrentDataBrokerTest
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / impl / test / Bug2562DeserializedUnkeyedListTest.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.controller.md.sal.binding.impl.test;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertContains;
13 import static org.opendaylight.controller.md.sal.binding.test.AssertCollections.assertEmpty;
14
15 import java.util.ArrayList;
16 import org.junit.Test;
17 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
18 import org.opendaylight.controller.md.sal.binding.test.AbstractDataChangeListenerTest;
19 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
20 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
21 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
22 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.Root;
23 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.RootBuilder;
24 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.Fooroot;
25 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.FoorootBuilder;
26 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.Barroot;
27 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootBuilder;
28 import org.opendaylight.yang.gen.v1.opendaylight.test.bug._2562.namespace.rev160101.root.fooroot.BarrootKey;
29 import org.opendaylight.yangtools.yang.binding.DataObject;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31
32 public class Bug2562DeserializedUnkeyedListTest extends AbstractDataChangeListenerTest {
33     private static final InstanceIdentifier<Root> ROOT_PATH = InstanceIdentifier.create(Root.class);
34
35     private void writeRoot(final LogicalDatastoreType store) {
36         final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction();
37         final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).setKey(new BarrootKey(2)).build();
38         final ArrayList barRootList = new ArrayList();
39         barRootList.add(barRoot);
40         final Fooroot fooRoot = new FoorootBuilder().setBarroot(barRootList).build();
41         final ArrayList fooRootList = new ArrayList();
42         fooRootList.add(fooRoot);
43         final Root root = new RootBuilder().setFooroot(fooRootList).build();
44
45         readWriteTransaction.put(store, ROOT_PATH, root);
46         assertCommit(readWriteTransaction.submit());
47     }
48
49     @Test
50     public void writeListToList2562Root() {
51         final AbstractDataChangeListenerTest.TestListener listenerRoot = createListener(LogicalDatastoreType.CONFIGURATION,
52                 ROOT_PATH, AsyncDataBroker.DataChangeScope.ONE, false);
53         writeRoot(LogicalDatastoreType.CONFIGURATION);
54         final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> eventRoot = listenerRoot.event();
55
56         assertContains(eventRoot.getCreatedData(), ROOT_PATH);
57         assertEmpty(eventRoot.getUpdatedData());
58         assertEmpty(eventRoot.getRemovedPaths());
59         assertNotNull(eventRoot.toString());
60     }
61 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.