X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FDeleteNestedAugmentationListenParentTest.java;h=213f62e8b3a011b455a42f43f2775ca17e49f337;hp=735138a530ab801149adbaceb79e38c3b27d92b9;hb=4f82c49691f091f0ba6b09a07525edb246f17321;hpb=c7fb98e7830a1eb8791cf70295f026138037e407 diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java index 735138a530..213f62e8b3 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DeleteNestedAugmentationListenParentTest.java @@ -1,90 +1,86 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.sal.binding.test.bugfix; import static org.junit.Assert.assertFalse; +import com.google.common.util.concurrent.SettableFuture; import java.util.concurrent.ExecutionException; - +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; -import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; +import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.statistics.FlowStatisticsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugment; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.List11SimpleAugmentBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.TllComplexAugment; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.List1Key; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.aug.grouping.list1.List11Key; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import com.google.common.util.concurrent.SettableFuture; - -@SuppressWarnings("deprecation") public class DeleteNestedAugmentationListenParentTest extends AbstractDataServiceTest { - private static final NodeKey NODE_KEY = new NodeKey(new NodeId("foo")); + private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo"); - private static final TableKey TABLE_KEY = new TableKey((short) 0); + private static final List1Key LIST1_KEY = new List1Key("one"); - private static final FlowKey FLOW_KEY = new FlowKey(new FlowId("100")); + private static final List11Key LIST11_KEY = new List11Key(100); - private static final InstanceIdentifier NODE_AUGMENT_PATH = InstanceIdentifier.builder(Nodes.class) - .child(Node.class,NODE_KEY) - .augmentation(FlowCapableNode.class) + private static final InstanceIdentifier TLL_COMPLEX_AUGMENT_PATH = InstanceIdentifier.builder(Top.class) + .child(TopLevelList.class,FOO_KEY) + .augmentation(TllComplexAugment.class) .build(); - private static final InstanceIdentifier FLOW_PATH = NODE_AUGMENT_PATH.builder() - .child(Table.class,TABLE_KEY) - .child(Flow.class,FLOW_KEY) + private static final InstanceIdentifier LIST11_PATH = TLL_COMPLEX_AUGMENT_PATH.builder() + .child(List1.class,LIST1_KEY) + .child(List11.class,LIST11_KEY) .build(); @Test - public void deleteChildListenParent() throws InterruptedException, ExecutionException { - DataModificationTransaction initTx = baDataService.beginTransaction(); - - initTx.putOperationalData(FLOW_PATH, flow()); - initTx.commit().get(); - - final SettableFuture, DataObject>> event = SettableFuture.create(); + public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException { + DataBroker dataBroker = testContext.getDataBroker(); + final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction(); - baDataService.registerDataChangeListener(FLOW_PATH, new DataChangeListener() { + initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, createList11(), true); + initTx.submit().get(5, TimeUnit.SECONDS); - @Override - public void onDataChanged(final DataChangeEvent, DataObject> change) { - event.set(change); - } - }); + final SettableFuture, DataObject>> event = SettableFuture.create(); + dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, + change -> event.set(change), DataChangeScope.SUBTREE); - DataModificationTransaction deleteTx = baDataService.beginTransaction(); - deleteTx.removeOperationalData(FLOW_PATH.augmentation(FlowStatisticsData.class)); - deleteTx.commit().get(); + final WriteTransaction deleteTx = dataBroker.newWriteOnlyTransaction(); + deleteTx.delete(LogicalDatastoreType.OPERATIONAL, LIST11_PATH.augmentation(List11SimpleAugment.class)); + deleteTx.submit().get(5, TimeUnit.SECONDS); - DataChangeEvent, DataObject> receivedEvent = event.get(); - assertFalse(receivedEvent.getRemovedOperationalData().contains(NODE_AUGMENT_PATH)); + AsyncDataChangeEvent, DataObject> receivedEvent = event.get(); + assertFalse(receivedEvent.getRemovedPaths().contains(TLL_COMPLEX_AUGMENT_PATH)); } - private Flow flow() { - FlowBuilder builder = new FlowBuilder() - .setKey(FLOW_KEY) - .addAugmentation(FlowStatisticsData.class,new FlowStatisticsDataBuilder() - .setFlowStatistics(new FlowStatisticsBuilder().build()) - .build()) - .setBarrier(true) - .setMatch(new MatchBuilder() - .build()) - ; + private List11 createList11() { + List11Builder builder = new List11Builder() + .setKey(LIST11_KEY) + .addAugmentation(List11SimpleAugment.class,new List11SimpleAugmentBuilder() + .setAttrStr2("bad").build()) + .setAttrStr("good"); return builder.build(); } -} \ No newline at end of file +}