Bump upstreams
[openflowplugin.git] / applications / lldp-speaker / src / test / java / org / opendaylight / openflowplugin / applications / lldpspeaker / NodeConnectorInventoryEventTranslatorTest.java
index cdd2ed622cae9c798eb7d36d0394affbb35cf486..9db3e2fe7396d6637acc60b33e1ad4aaa294d643 100644 (file)
@@ -5,19 +5,16 @@
  * 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.lldpspeaker;
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
 import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.SUBTREE_MODIFIED;
 import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,7 +32,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-
 /**
  * Tests for {@link NodeConnectorInventoryEventTranslator}.
  */
@@ -63,13 +59,13 @@ public class NodeConnectorInventoryEventTranslatorTest {
     /**
      * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorAdded} is called
      * for each FlowCapableNodeConnector item added in
-     * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
+     * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}.
      */
     @Test
     public void testNodeConnectorCreation() {
         DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, NODE_CONNECTOR_INSTANCE_IDENTIFIER,
                                                                         FLOW_CAPABLE_NODE_CONNECTOR);
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
+        translator.onDataTreeChanged(List.of(dataTreeModification));
         verify(eventsObserver).nodeConnectorAdded(ID, FLOW_CAPABLE_NODE_CONNECTOR);
     }
 
@@ -80,8 +76,8 @@ public class NodeConnectorInventoryEventTranslatorTest {
     public void testNodeConnectorCreationLinkDown() {
         FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
         DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc);
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
-        verifyZeroInteractions(eventsObserver);
+        translator.onDataTreeChanged(List.of(dataTreeModification));
+        verifyNoInteractions(eventsObserver);
     }
 
     /**
@@ -91,63 +87,63 @@ public class NodeConnectorInventoryEventTranslatorTest {
     public void testNodeConnectorCreationAdminDown() {
         FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(false, true).build();
         DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, ID, fcnc);
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
-        verifyZeroInteractions(eventsObserver);
+        translator.onDataTreeChanged(List.of(dataTreeModification));
+        verifyNoInteractions(eventsObserver);
     }
 
     /**
      * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
      * for each FlowCapableNodeConnector item that have link down state removed in
-     * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
+     * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}.
      */
     @Test
     public void testNodeConnectorUpdateToLinkDown() {
         FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(true, false).build();
         DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED,
                                                                         NODE_CONNECTOR_INSTANCE_IDENTIFIER, fcnc);
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
+        translator.onDataTreeChanged(List.of(dataTreeModification));
         verify(eventsObserver).nodeConnectorRemoved(ID);
     }
 
     /**
      * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
      * for each FlowCapableNodeConnector item with administrative down state removed in
-     * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
+     * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}.
      */
     @Test
     public void testNodeConnectorUpdateToAdminDown() {
         FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector(false, true).build();
         DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED,
                                                                         NODE_CONNECTOR_INSTANCE_IDENTIFIER, fcnc);
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
+        translator.onDataTreeChanged(List.of(dataTreeModification));
         verify(eventsObserver).nodeConnectorRemoved(ID);
     }
 
     /**
      * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorAdded} is called
      * for each FlowCapableNodeConnector item with administrative up and link up state added in
-     * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}.
+     * {@link org.opendaylight.md}.
      */
     @Test
     public void testNodeConnectorUpdateToUp() {
         DataTreeModification dataTreeModification = setupDataTreeChange(SUBTREE_MODIFIED,
                                                                         NODE_CONNECTOR_INSTANCE_IDENTIFIER,
                                                                         FLOW_CAPABLE_NODE_CONNECTOR);
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
+        translator.onDataTreeChanged(List.of(dataTreeModification));
         verify(eventsObserver).nodeConnectorAdded(ID, FLOW_CAPABLE_NODE_CONNECTOR);
     }
 
     /**
      * Test that checks if {@link NodeConnectorEventsObserver#nodeConnectorRemoved} is called
      * for each FlowCapableNodeConnector path that
-     * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification} return.
+     * {@link org.opendaylight.mdsal.binding.api.DataTreeModification} return.
      */
     @Test
     public void testNodeConnectorRemoval() {
         DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, NODE_CONNECTOR_INSTANCE_IDENTIFIER,
                                                                         null);
         // Invoke NodeConnectorInventoryEventTranslator and check result
-        translator.onDataTreeChanged(Collections.singleton(dataTreeModification));
+        translator.onDataTreeChanged(List.of(dataTreeModification));
         verify(eventsObserver).nodeConnectorRemoved(ID);
     }
 
@@ -161,11 +157,10 @@ public class NodeConnectorInventoryEventTranslatorTest {
         // Create prerequisites
         InstanceIdentifier<NodeConnector> id2 = TestUtils.createNodeConnectorId("openflow:1", "openflow:1:2");
         InstanceIdentifier<FlowCapableNodeConnector> iiToConnector2 = id2.augmentation(FlowCapableNodeConnector.class);
-        List<DataTreeModification> modifications = new ArrayList();
-        modifications.add(setupDataTreeChange(WRITE, NODE_CONNECTOR_INSTANCE_IDENTIFIER, FLOW_CAPABLE_NODE_CONNECTOR));
-        modifications.add(setupDataTreeChange(DELETE, iiToConnector2, null));
         // Invoke onDataTreeChanged and check that both observers notified
-        translator.onDataTreeChanged(modifications);
+        translator.onDataTreeChanged(List.of(
+            setupDataTreeChange(WRITE, NODE_CONNECTOR_INSTANCE_IDENTIFIER, FLOW_CAPABLE_NODE_CONNECTOR),
+            setupDataTreeChange(DELETE, iiToConnector2, null)));
         verify(eventsObserver).nodeConnectorAdded(ID, FLOW_CAPABLE_NODE_CONNECTOR);
         verify(eventsObserver).nodeConnectorRemoved(id2);
         verify(eventsObserver2).nodeConnectorAdded(ID, FLOW_CAPABLE_NODE_CONNECTOR);
@@ -177,16 +172,14 @@ public class NodeConnectorInventoryEventTranslatorTest {
         translator.close();
     }
 
-    private <T extends DataObject> DataTreeModification setupDataTreeChange(final ModificationType type,
-                                                                            final InstanceIdentifier<T> ii,
-                                                                            final FlowCapableNodeConnector connector) {
+    private static <T extends DataObject> DataTreeModification setupDataTreeChange(final ModificationType type,
+            final InstanceIdentifier<T> ii, final FlowCapableNodeConnector connector) {
         final DataTreeModification dataTreeModification = mock(DataTreeModification.class);
         when(dataTreeModification.getRootNode()).thenReturn(mock(DataObjectModification.class));
-        DataTreeIdentifier<T> identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii);
-        when(dataTreeModification.getRootNode().getModificationType()).thenReturn(type);
+        DataTreeIdentifier<T> identifier = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, ii);
+        when(dataTreeModification.getRootNode().modificationType()).thenReturn(type);
         when(dataTreeModification.getRootPath()).thenReturn(identifier);
-        when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(connector);
+        when(dataTreeModification.getRootNode().dataAfter()).thenReturn(connector);
         return dataTreeModification;
-
     }
 }