Merge "Fix transaction manager closing."
[openflowplugin.git] / applications / notification-supplier / src / test / java / org / opendaylight / openflowplugin / applications / notification / supplier / impl / item / GroupNotificationSupplierImplTest.java
index b36341509809065dc5fcc88b4ae986eecacf3fc5..ce54af8f7f7bbb6af1c55c8d48f60bafa5c896bd 100644 (file)
@@ -16,10 +16,6 @@ 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;
@@ -31,7 +27,6 @@ import org.opendaylight.openflowplugin.applications.notification.supplier.impl.h
 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.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
@@ -43,17 +38,16 @@ 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.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
- *
+ * Test for {@link GroupNotificationSupplierImpl}.
  */
 public class GroupNotificationSupplierImplTest {
 
     private static final String FLOW_NODE_ID = "openflow:111";
     private static final Long GROUP_ID = 111L;
-    private static final Long  UPDATED_GROUP_ID = 100L;
+    private static final Long UPDATED_GROUP_ID = 100L;
 
     private GroupNotificationSupplierImpl notifSupplierImpl;
     private NotificationProviderService notifProviderService;
@@ -64,7 +58,7 @@ public class GroupNotificationSupplierImplTest {
         notifProviderService = mock(NotificationProviderService.class);
         dataBroker = mock(DataBroker.class);
         notifSupplierImpl = new GroupNotificationSupplierImpl(notifProviderService, dataBroker);
-        TestSupplierVerifyHelper.verifyDataChangeRegistration(dataBroker);
+        TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker);
     }
 
     @Test(expected = NullPointerException.class)
@@ -74,12 +68,12 @@ public class GroupNotificationSupplierImplTest {
 
     @Test(expected = NullPointerException.class)
     public void testNullableChangeEvent() {
-        notifSupplierImpl.onDataTreeChanged( TestChangeEventBuildHelper.createNullTestDataTreeEvent());
+        notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createNullTestDataTreeEvent());
     }
 
     @Test
     public void testEmptyChangeEvent() {
-        notifSupplierImpl.onDataTreeChanged( TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
+        notifSupplierImpl.onDataTreeChanged(TestChangeEventBuildHelper.createEmptyTestDataTreeEvent());
     }
 
     @Test
@@ -87,14 +81,17 @@ public class GroupNotificationSupplierImplTest {
         final GroupAdded notification = notifSupplierImpl.createNotification(createTestGroup(), createTestGroupPath());
         assertNotNull(notification);
         assertEquals(GROUP_ID, notification.getGroupId().getValue());
-        assertEquals(GROUP_ID, notification.getGroupRef().getValue().firstKeyOf(Group.class, GroupKey.class).getGroupId().getValue());
-        assertEquals(FLOW_NODE_ID, notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
+        assertEquals(GROUP_ID,
+                     notification.getGroupRef().getValue().firstKeyOf(Group.class, GroupKey.class).getGroupId()
+                             .getValue());
+        assertEquals(FLOW_NODE_ID,
+                     notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
     }
 
     @Test
     public void testCreateChangeEvent() {
-        final TestData testData = new TestData(createTestGroupPath(),null,createTestGroup(),
-                DataObjectModification.ModificationType.WRITE);
+        final TestData testData = new TestData(createTestGroupPath(), null, createTestGroup(),
+                                               DataObjectModification.ModificationType.WRITE);
         Collection<DataTreeModification<Group>> collection = new ArrayList<>();
         collection.add(testData);
         notifSupplierImpl.onDataTreeChanged(collection);
@@ -113,17 +110,21 @@ public class GroupNotificationSupplierImplTest {
 
     @Test
     public void testUpdate() {
-        final GroupUpdated notification = notifSupplierImpl.updateNotification(createTestGroup(), createTestGroupPath());
+        final GroupUpdated notification = notifSupplierImpl
+                .updateNotification(createTestGroup(), createTestGroupPath());
         assertNotNull(notification);
         assertEquals(GROUP_ID, notification.getGroupId().getValue());
-        assertEquals(GROUP_ID, notification.getGroupRef().getValue().firstKeyOf(Group.class, GroupKey.class).getGroupId().getValue());
-        assertEquals(FLOW_NODE_ID, notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
+        assertEquals(GROUP_ID,
+                     notification.getGroupRef().getValue().firstKeyOf(Group.class, GroupKey.class).getGroupId()
+                             .getValue());
+        assertEquals(FLOW_NODE_ID,
+                     notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
     }
 
     @Test
     public void testUpdateChangeEvent() {
-        final TestData testData = new TestData(createTestGroupPath(),createTestGroup(),createUpdatedTestGroup(),
-                DataObjectModification.ModificationType.SUBTREE_MODIFIED);
+        final TestData testData = new TestData(createTestGroupPath(), createTestGroup(), createUpdatedTestGroup(),
+                                               DataObjectModification.ModificationType.SUBTREE_MODIFIED);
         Collection<DataTreeModification<Group>> collection = new ArrayList<>();
         collection.add(testData);
         notifSupplierImpl.onDataTreeChanged(collection);
@@ -145,14 +146,17 @@ public class GroupNotificationSupplierImplTest {
         final GroupRemoved notification = notifSupplierImpl.deleteNotification(createTestGroupPath());
         assertNotNull(notification);
         assertEquals(GROUP_ID, notification.getGroupId().getValue());
-        assertEquals(GROUP_ID, notification.getGroupRef().getValue().firstKeyOf(Group.class, GroupKey.class).getGroupId().getValue());
-        assertEquals(FLOW_NODE_ID, notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
+        assertEquals(GROUP_ID,
+                     notification.getGroupRef().getValue().firstKeyOf(Group.class, GroupKey.class).getGroupId()
+                             .getValue());
+        assertEquals(FLOW_NODE_ID,
+                     notification.getNode().getValue().firstKeyOf(Node.class, NodeKey.class).getId().getValue());
     }
 
     @Test
     public void testDeleteChangeEvent() {
-        final TestData testData = new TestData(createTestGroupPath(),createTestGroup(),null,
-                DataObjectModification.ModificationType.DELETE);
+        final TestData testData = new TestData(createTestGroupPath(), createTestGroup(), null,
+                                               DataObjectModification.ModificationType.DELETE);
         Collection<DataTreeModification<Group>> collection = new ArrayList<>();
         collection.add(testData);
         notifSupplierImpl.onDataTreeChanged(collection);