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
9 package org.opendaylight.controller.sal.binding.test.bugfix;
11 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
32 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
33 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
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.builder(Top.class)
44 .child(TopLevelList.class,FOO_KEY)
45 .augmentation(TllComplexAugment.class)
48 private static final InstanceIdentifier<List11> LIST11_PATH = TLL_COMPLEX_AUGMENT_PATH.builder()
49 .child(List1.class,LIST1_KEY)
50 .child(List11.class,LIST11_KEY)
54 protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
55 return ImmutableSet.of(BindingReflections.getModuleInfo(Top.class),
56 BindingReflections.getModuleInfo(List11SimpleAugment.class));
60 public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
61 DataBroker dataBroker = getDataBroker();
62 final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();
64 List11 list11Before = createList11();
65 initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, list11Before, true);
66 initTx.submit().get(5, TimeUnit.SECONDS);
68 List11 list11After = new List11Builder().setKey(LIST11_KEY).setAttrStr("good").build();
70 final TestListener<List11> listener = createListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
71 added(LIST11_PATH, list11Before), subtreeModified(LIST11_PATH, list11Before, list11After));
73 final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction();
74 deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class));
75 deleteTx.submit().get(5, TimeUnit.SECONDS);
80 private List11 createList11() {
81 List11Builder builder = new List11Builder()
83 .addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder()
84 .setAttrStr2("bad").build())
86 return builder.build();