Remove deprecation suppression
[controller.git] / opendaylight / md-sal / sal-binding-dom-it / src / test / java / org / opendaylight / controller / sal / binding / test / bugfix / WriteParentReadChildTest.java
1 /*
2  * Copyright (c) 2014 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.sal.binding.test.bugfix;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import com.google.common.collect.ImmutableList;
15 import org.junit.Test;
16 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
17 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
18 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Builder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
29 import org.opendaylight.yangtools.yang.binding.DataObject;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31 import org.opendaylight.yangtools.yang.common.RpcResult;
32
33 public class WriteParentReadChildTest extends AbstractDataServiceTest {
34
35     private static final int LIST11_ID = 1234;
36     private static final String LIST1_NAME = "bar";
37     private static final String TLL_NAME = "foo";
38
39     private static final TopLevelListKey TLL_KEY = new TopLevelListKey(TLL_NAME);
40     private static final List11Key LIST11_KEY = new List11Key(LIST11_ID);
41     private static final List1Key LIST1_KEY = new List1Key(LIST1_NAME);
42
43     private static final InstanceIdentifier<TopLevelList> TLL_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
44             .child(TopLevelList.class, TLL_KEY).toInstance();
45
46     private static final InstanceIdentifier<List1> LIST1_INSTANCE_ID_BA = //
47             TLL_INSTANCE_ID_BA.builder() //
48             .augmentation(TllComplexAugment.class).child(List1.class, LIST1_KEY).build();
49
50     private static final InstanceIdentifier<? extends DataObject> LIST11_INSTANCE_ID_BA = //
51             LIST1_INSTANCE_ID_BA.child(List11.class, LIST11_KEY);
52     /**
53      *
54      * The scenario tests writing parent node, which also contains child items
55      * and then reading child directly, by specifying path to the child.
56      *
57      * Expected behaviour is child is returned.
58      *
59      * @throws Exception
60      */
61     @Test
62     public void writeParentReadChild() throws Exception {
63
64         DataModificationTransaction modification = baDataService.beginTransaction();
65
66         List11 list11 = new List11Builder() //
67                 .setKey(LIST11_KEY) //
68                 .setAttrStr("primary")
69                 .build();
70
71         List1 list1 = new List1Builder()
72             .setKey(LIST1_KEY)
73             .setList11(ImmutableList.of(list11))
74         .build();
75
76         modification.putConfigurationData(LIST1_INSTANCE_ID_BA, list1);
77         RpcResult<TransactionStatus> ret = modification.commit().get();
78         assertNotNull(ret);
79         assertEquals(TransactionStatus.COMMITED, ret.getResult());
80
81         DataObject readList1 = baDataService.readConfigurationData(LIST1_INSTANCE_ID_BA);
82         assertNotNull("Readed table should not be nul.", readList1);
83         assertTrue(readList1 instanceof List1);
84
85         DataObject readList11 = baDataService.readConfigurationData(LIST11_INSTANCE_ID_BA);
86         assertNotNull("Readed flow should not be null.",readList11);
87         assertTrue(readList11 instanceof List11);
88         assertEquals(list11, readList11);
89
90     }
91 }

©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.