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;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
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;
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.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class FlowStatNotificationSupplierImplTest {
private static final Short FLOW_TABLE_ID = 111;
private static final String FLOW_ID = "test-flow-111";
private FlowStatNotificationSupplierImpl 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 FlowStatNotificationSupplierImpl(notifProviderService, dataBroker);
- TestSupplierVerifyHelper.verifyDataChangeRegistration(dataBroker);
+ TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
}
@Test(expected = NullPointerException.class)
@Test(expected = NullPointerException.class)
public void testNullableChangeEvent() {
- notifSupplierImpl.onDataTreeChanged( TestChangeEventBuildHelper.createNullTestDataTreeEvent());
+ notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
}
@Test
@Test
public void testCreate() {
- final FlowsStatisticsUpdate notification = notifSupplierImpl.createNotification(createTestFlowStat(), createTestFlowStatPath());
+ final FlowsStatisticsUpdate notification = notifSupplierImpl
+ .createNotification(createTestFlowStat(), createTestFlowStatPath());
assertNotNull(notification);
assertEquals(FLOW_NODE_ID, notification.getId().getValue());
}
@Test
- public void testCreateChangeEvent() {
- final TestData testData = new TestData(createTestFlowStatPath(),null,createTestFlowStat(),
- DataObjectModification.ModificationType.WRITE);
+ public void testCreateChangeEvent() throws InterruptedException {
+ final TestData<FlowStatistics> testData = new TestData<>(createTestFlowStatPath(), null, createTestFlowStat(),
+ DataObjectModification.ModificationType.WRITE);
Collection<DataTreeModification<FlowStatistics>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
- verify(notifProviderService, times(1)).publish(Matchers.any(FlowsStatisticsUpdate.class));
+ verify(notifProviderService, times(1)).putNotification(any(FlowsStatisticsUpdate.class));
}
@Test(expected = IllegalArgumentException.class)