Bug-5644: Fix checkstyle invocation for l2switch builds
[l2switch.git] / arphandler / implementation / src / test / java / org / opendaylight / l2switch / arphandler / core / ArpPacketHandlerTest.java
index 83df16c7bfab67bfb2e0ecc532d83d16c0fc2098..e236a857da421b69ad580b8325e243a84e883acd 100644 (file)
@@ -7,6 +7,11 @@
  */
 package org.opendaylight.l2switch.arphandler.core;
 
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.util.ArrayList;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.MockitoAnnotations;
@@ -20,104 +25,88 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.basepacket.rev140528
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.basepacket.rev140528.packet.chain.grp.packet.chain.packet.RawPacketBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.ethernet.rev140528.ethernet.packet.received.packet.chain.packet.EthernetPacketBuilder;
 
-import java.util.ArrayList;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
 public class ArpPacketHandlerTest {
 
-  @MockitoAnnotations.Mock private PacketDispatcher packetDispatcher;
-  private ArpPacketHandler arpPacketHandler;
-
-  @Before
-  public void initMocks() {
-    MockitoAnnotations.initMocks(this);
-    arpPacketHandler = new ArpPacketHandler(packetDispatcher);
-  }
-
-  @Test
-  public void onArpPacketReceivedTest() throws Exception {
-    ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new RawPacketBuilder().build())
-      .build());
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new EthernetPacketBuilder().build())
-      .build());
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new ArpPacketBuilder().build())
-      .build());
-    ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
-    arpPacketHandler.onArpPacketReceived(arpReceived);
-
-    verify(packetDispatcher, times(1)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
-
-  @Test
-  public void onArpPacketReceivedTest_NullInput() throws Exception {
-    arpPacketHandler.onArpPacketReceived(null);
-    verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
-
-  @Test
-  public void onArpPacketReceivedTest_NullPacketChain() throws Exception {
-    ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().build();
-    arpPacketHandler.onArpPacketReceived(arpReceived);
-    verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
-
-  @Test
-  public void onArpPacketReceivedTest_EmptyPacketChain() throws Exception {
-    ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
-    ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
-    arpPacketHandler.onArpPacketReceived(arpReceived);
-    verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
-
-  @Test
-  public void onArpPacketReceivedTest_NoRawPacket() throws Exception {
-    ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new EthernetPacketBuilder().build())
-      .build());
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new ArpPacketBuilder().build())
-      .build());
-    ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
-    arpPacketHandler.onArpPacketReceived(arpReceived);
-
-    verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
-
-  @Test
-  public void onArpPacketReceivedTest_NoEthernetPacket() throws Exception {
-    ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new RawPacketBuilder().build())
-      .build());
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new ArpPacketBuilder().build())
-      .build());
-    ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
-    arpPacketHandler.onArpPacketReceived(arpReceived);
-
-    verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
-
-  @Test
-  public void onArpPacketReceivedTest_NoArpPacket() throws Exception {
-    ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new RawPacketBuilder().build())
-      .build());
-    packetChainList.add(new PacketChainBuilder()
-      .setPacket(new EthernetPacketBuilder().build())
-      .build());
-    ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
-    arpPacketHandler.onArpPacketReceived(arpReceived);
-
-    verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class), any(MacAddress.class), any(MacAddress.class));
-  }
+    @MockitoAnnotations.Mock
+    private PacketDispatcher packetDispatcher;
+    private ArpPacketHandler arpPacketHandler;
+
+    @Before
+    public void initMocks() {
+        MockitoAnnotations.initMocks(this);
+        arpPacketHandler = new ArpPacketHandler(packetDispatcher);
+    }
+
+    @Test
+    public void onArpPacketReceivedTest() throws Exception {
+        ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
+        packetChainList.add(new PacketChainBuilder().setPacket(new RawPacketBuilder().build()).build());
+        packetChainList.add(new PacketChainBuilder().setPacket(new EthernetPacketBuilder().build()).build());
+        packetChainList.add(new PacketChainBuilder().setPacket(new ArpPacketBuilder().build()).build());
+        ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
+        arpPacketHandler.onArpPacketReceived(arpReceived);
+
+        verify(packetDispatcher, times(1)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
+
+    @Test
+    public void onArpPacketReceivedTest_NullInput() throws Exception {
+        arpPacketHandler.onArpPacketReceived(null);
+        verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
+
+    @Test
+    public void onArpPacketReceivedTest_NullPacketChain() throws Exception {
+        ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().build();
+        arpPacketHandler.onArpPacketReceived(arpReceived);
+        verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
+
+    @Test
+    public void onArpPacketReceivedTest_EmptyPacketChain() throws Exception {
+        ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
+        ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
+        arpPacketHandler.onArpPacketReceived(arpReceived);
+        verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
+
+    @Test
+    public void onArpPacketReceivedTest_NoRawPacket() throws Exception {
+        ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
+        packetChainList.add(new PacketChainBuilder().setPacket(new EthernetPacketBuilder().build()).build());
+        packetChainList.add(new PacketChainBuilder().setPacket(new ArpPacketBuilder().build()).build());
+        ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
+        arpPacketHandler.onArpPacketReceived(arpReceived);
+
+        verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
+
+    @Test
+    public void onArpPacketReceivedTest_NoEthernetPacket() throws Exception {
+        ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
+        packetChainList.add(new PacketChainBuilder().setPacket(new RawPacketBuilder().build()).build());
+        packetChainList.add(new PacketChainBuilder().setPacket(new ArpPacketBuilder().build()).build());
+        ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
+        arpPacketHandler.onArpPacketReceived(arpReceived);
+
+        verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
+
+    @Test
+    public void onArpPacketReceivedTest_NoArpPacket() throws Exception {
+        ArrayList<PacketChain> packetChainList = new ArrayList<PacketChain>();
+        packetChainList.add(new PacketChainBuilder().setPacket(new RawPacketBuilder().build()).build());
+        packetChainList.add(new PacketChainBuilder().setPacket(new EthernetPacketBuilder().build()).build());
+        ArpPacketReceived arpReceived = new ArpPacketReceivedBuilder().setPacketChain(packetChainList).build();
+        arpPacketHandler.onArpPacketReceived(arpReceived);
+
+        verify(packetDispatcher, times(0)).dispatchPacket(any(byte[].class), any(NodeConnectorRef.class),
+                any(MacAddress.class), any(MacAddress.class));
+    }
 }