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%2FNodeConnectorNotificationSupplierImplTest.java;h=cc62118c09e2b388c01c065b0a16bcbd6b08cea7;hb=1c1d2b76c7c6a071a9dad151851e614f9f9ec8ef;hp=3c6b038b0d276e4c506f4eb2662feeb096820eaa;hpb=85a27decf79695a8a0a2dcd21325dc5336398860;p=openflowplugin.git diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java index 3c6b038b0d..cc62118c09 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java @@ -14,19 +14,26 @@ 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.HashSet; import java.util.Map; import java.util.Set; + 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.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.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated; @@ -44,7 +51,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; */ public class NodeConnectorNotificationSupplierImplTest { - private static final String FLOW_NODE_ID = "test-111"; + private static final String FLOW_NODE_ID = "openflow:111"; private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111"; private NodeConnectorNotificationSupplierImpl notifSupplierImpl; private NotificationProviderService notifProviderService; @@ -58,19 +65,19 @@ public class NodeConnectorNotificationSupplierImplTest { TestSupplierVerifyHelper.verifyDataChangeRegistration(dataBroker); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = NullPointerException.class) public void testNullChangeEvent() { - notifSupplierImpl.onDataChanged(null); + notifSupplierImpl.onDataTreeChanged(null); } - @Test + @Test(expected = NullPointerException.class) public void testNullableChangeEvent() { - notifSupplierImpl.onDataChanged(TestChangeEventBuildHelper.createEmptyTestDataEvent()); + notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent()); } @Test public void testEmptyChangeEvent() { - notifSupplierImpl.onDataChanged(TestChangeEventBuildHelper.createEmptyTestDataEvent()); + notifSupplierImpl.onDataTreeChanged( TestChangeEventBuildHelper.createEmptyTestDataTreeEvent()); } @Test @@ -86,9 +93,11 @@ public class NodeConnectorNotificationSupplierImplTest { @Test public void testCreateChangeEvent() { - final Map, DataObject> createdData = new HashMap<>(); - createdData.put(createTestFlowCapableConnectorNodePath(), createTestFlowCapableNodeConnecor()); - notifSupplierImpl.onDataChanged(TestChangeEventBuildHelper.createTestDataEvent(createdData, null, null)); + final TestData testData = new TestData(createTestFlowCapableConnectorNodePath(),null, + createTestFlowCapableNodeConnecor(),DataObjectModification.ModificationType.WRITE); + Collection> collection = new ArrayList<>(); + collection.add(testData); + notifSupplierImpl.onDataTreeChanged(collection); verify(notifProviderService, times(1)).publish(Matchers.any(NodeConnectorUpdated.class)); } @@ -113,9 +122,11 @@ public class NodeConnectorNotificationSupplierImplTest { @Test public void testDeleteChangeEvent() { - final Set> removeData = new HashSet<>(); - removeData.add(createTestFlowCapableConnectorNodePath()); - notifSupplierImpl.onDataChanged(TestChangeEventBuildHelper.createTestDataEvent(null, null, removeData)); + final TestData testData = new TestData(createTestFlowCapableConnectorNodePath(), + createTestFlowCapableNodeConnecor(),null,DataObjectModification.ModificationType.DELETE); + Collection> collection = new ArrayList<>(); + collection.add(testData); + notifSupplierImpl.onDataTreeChanged(collection); verify(notifProviderService, times(1)).publish(Matchers.any(NodeConnectorRemoved.class)); }