X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fnotification-supplier%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Fnotification%2Fsupplier%2Fimpl%2Fitem%2FMeterNotificationSupplierImplTest.java;h=e786f99eb962af505caa846a0482393082cf5da6;hb=cfe3a97837951ebbedb337dc988027f10c49f714;hp=3ca4e09d6e8ba8183582fc42ea7a5f8c7e2c1433;hpb=2adfa46d686ca524526a1916d6b07f8de01fc86c;p=openflowplugin.git diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java index 3ca4e09d6e..e786f99eb9 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java @@ -5,11 +5,11 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -18,11 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.mockito.Matchers; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -51,12 +50,12 @@ public class MeterNotificationSupplierImplTest { private static final Long UPDATED_METER_ID = 100L; private MeterNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new MeterNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -83,20 +82,20 @@ public class MeterNotificationSupplierImplTest { assertNotNull(notification); assertEquals(METER_ID, notification.getMeterId().getValue()); assertEquals(METER_ID, - notification.getMeterRef().getValue().firstKeyOf(Meter.class, MeterKey.class).getMeterId() + notification.getMeterRef().getValue().firstKeyOf(Meter.class).getMeterId() .getValue()); assertEquals(FLOW_NODE_ID, - notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue()); + notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue()); } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestMeterPath(), null, createTestMeter(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterPath(), null, createTestMeter(), + DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(Matchers.any(MeterAdded.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterAdded.class)); } @Test(expected = IllegalArgumentException.class) @@ -116,20 +115,21 @@ public class MeterNotificationSupplierImplTest { assertNotNull(notification); assertEquals(METER_ID, notification.getMeterId().getValue()); assertEquals(METER_ID, - notification.getMeterRef().getValue().firstKeyOf(Meter.class, MeterKey.class).getMeterId() + notification.getMeterRef().getValue().firstKeyOf(Meter.class).getMeterId() .getValue()); assertEquals(FLOW_NODE_ID, - notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue()); + notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue()); } @Test - public void testUdateChangeEvent() { - final TestData testData = new TestData(createTestMeterPath(), createTestMeter(), createUpdatedTestMeter(), - DataObjectModification.ModificationType.SUBTREE_MODIFIED); + public void testUdateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterPath(), createTestMeter(), + createUpdatedTestMeter(), + DataObjectModification.ModificationType.SUBTREE_MODIFIED); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(Matchers.any(MeterUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterUpdated.class)); } @Test(expected = IllegalArgumentException.class) @@ -148,20 +148,20 @@ public class MeterNotificationSupplierImplTest { assertNotNull(notification); assertEquals(METER_ID, notification.getMeterId().getValue()); assertEquals(METER_ID, - notification.getMeterRef().getValue().firstKeyOf(Meter.class, MeterKey.class).getMeterId() + notification.getMeterRef().getValue().firstKeyOf(Meter.class).getMeterId() .getValue()); assertEquals(FLOW_NODE_ID, - notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue()); + notification.getNode().getValue().firstKeyOf(Node.class).getId().getValue()); } @Test - public void testDeleteChangeEvent() { - final TestData testData = new TestData(createTestMeterPath(), createTestMeter(), null, - DataObjectModification.ModificationType.DELETE); + public void testDeleteChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterPath(), createTestMeter(), null, + DataObjectModification.ModificationType.DELETE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(Matchers.any(MeterRemoved.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterRemoved.class)); } @Test(expected = IllegalArgumentException.class)