2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.binding.test.bugfix;
10 import com.google.common.collect.ImmutableSet;
12 import java.util.concurrent.ExecutionException;
13 import java.util.concurrent.TimeUnit;
14 import java.util.concurrent.TimeoutException;
15 import org.junit.Test;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
18 import org.opendaylight.controller.md.sal.binding.test.AbstractDataTreeChangeListenerTest;
19 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
20 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
35 public class DeleteNestedAugmentationListenParentTest extends AbstractDataTreeChangeListenerTest {
37 private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo");
39 private static final List1Key LIST1_KEY = new List1Key("one");
41 private static final List11Key LIST11_KEY = new List11Key(100);
43 private static final InstanceIdentifier<TllComplexAugment> TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier
45 .child(TopLevelList.class,FOO_KEY)
46 .augmentation(TllComplexAugment.class)
49 private static final InstanceIdentifier<List11> LIST11_PATH = TLL_COMPLEX_AUGMENT_PATH.builder()
50 .child(List1.class,LIST1_KEY)
51 .child(List11.class,LIST11_KEY)
55 protected Set<YangModuleInfo> getModuleInfos() throws Exception {
56 return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
57 BindingReflections.getModuleInfo(List11SimpleAugment.class));
61 public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
62 DataBroker dataBroker = getDataBroker();
63 final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();
65 List11 list11Before = createList11();
66 initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, list11Before, true);
67 initTx.submit().get(5, TimeUnit.SECONDS);
69 List11 list11After = new List11Builder().withKey(LIST11_KEY).setAttrStr("good").build();
71 final TestListener<List11> listener = createListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
72 added(LIST11_PATH, list11Before), subtreeModified(LIST11_PATH, list11Before, list11After));
74 final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction();
75 deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class));
76 deleteTx.submit().get(5, TimeUnit.SECONDS);
81 private static List11 createList11() {
82 List11Builder builder = new List11Builder()
84 .addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder()
85 .setAttrStr2("bad").build())
87 return builder.build();