Adjust unit test to YangModuleInfo API change
[controller.git] / opendaylight / md-sal / sal-binding-dom-it / src / test / java / org / opendaylight / controller / sal / binding / test / bugfix / DeleteNestedAugmentationListenParentTest.java
index 40d4591001212c05e716f9fd6b2898d37cc47267..213f62e8b3a011b455a42f43f2775ca17e49f337 100644 (file)
@@ -1,13 +1,25 @@
+/*
+ * 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.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;
@@ -23,9 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 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 TopLevelListKey FOO_KEY = new TopLevelListKey("foo");
@@ -46,28 +55,23 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic
 
 
     @Test
-    public void deleteChildListenParent() throws InterruptedException, ExecutionException {
-        DataModificationTransaction initTx = baDataService.beginTransaction();
-
-        initTx.putOperationalData(LIST11_PATH, createList11());
-        initTx.commit().get();
-
-        final SettableFuture<DataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
+    public void deleteChildListenParent() throws InterruptedException, ExecutionException, TimeoutException {
+        DataBroker dataBroker = testContext.getDataBroker();
+        final WriteTransaction initTx = dataBroker.newWriteOnlyTransaction();
 
-        baDataService.registerDataChangeListener(LIST11_PATH, new DataChangeListener() {
+        initTx.put(LogicalDatastoreType.OPERATIONAL, LIST11_PATH, createList11(), true);
+        initTx.submit().get(5, TimeUnit.SECONDS);
 
-            @Override
-            public void onDataChanged(final DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-                event.set(change);
-            }
-        });
+        final SettableFuture<AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject>> event = SettableFuture.create();
+        dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, LIST11_PATH,
+            change -> event.set(change), DataChangeScope.SUBTREE);
 
-        DataModificationTransaction deleteTx = baDataService.beginTransaction();
-        deleteTx.removeOperationalData(LIST11_PATH.augmentation(List11SimpleAugment.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<InstanceIdentifier<?>, DataObject> receivedEvent = event.get();
-        assertFalse(receivedEvent.getRemovedOperationalData().contains(TLL_COMPLEX_AUGMENT_PATH));
+        AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> receivedEvent = event.get();
+        assertFalse(receivedEvent.getRemovedPaths().contains(TLL_COMPLEX_AUGMENT_PATH));
     }
 
     private List11 createList11() {
@@ -79,4 +83,4 @@ public class DeleteNestedAugmentationListenParentTest extends AbstractDataServic
         return builder.build();
     }
 
-}
\ No newline at end of file
+}