Checkstyle: fix issues and enforce on lisp-proto
[lispflowmapping.git] / mappingservice / lisp-proto / src / test / java / org / opendaylight / lispflowmapping / lisp / util / LispAddressStringifierTest.java
index 912081bf2214163286762e120c692dc3c4c0516b..d9281f0b3f3e6b6a4cf1c42358f3eb6e443d2d70 100644 (file)
@@ -14,80 +14,60 @@ import com.google.common.io.BaseEncoding;
 import java.util.ArrayList;
 import java.util.List;
 import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.DistinguishedNameType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.ServicePathIdType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .AfiList;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .AfiListBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .ApplicationData;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .ApplicationDataBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .AsNumberBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .DistinguishedName;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .DistinguishedNameBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .ExplicitLocatorPath;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .ExplicitLocatorPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .InstanceId;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .InstanceIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Ipv4;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Ipv4Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Ipv4PrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Ipv6;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Ipv6PrefixBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .KeyValueAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .KeyValueAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .Mac;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .MacBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .NoAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .NoAddressBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .ServicePath;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .ServicePathBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .SourceDestKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .SourceDestKeyBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .explicit.locator.path.explicit.locator.path.Hop;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .explicit.locator.path.explicit.locator.path.HopBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
-        .explicit.locator.path.explicit.locator.path.HopKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AfiListBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ApplicationDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.AsNumberBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.DistinguishedName;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.DistinguishedNameBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPath;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ExplicitLocatorPathBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.InstanceId;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.InstanceIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4PrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6PrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.KeyValueAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePathBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKeyBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.Hop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv4AddressBinary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.inet.binary.types.rev160303.Ipv6AddressBinary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4BinaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6BinaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinaryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.XtrId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder;
 
@@ -104,12 +84,27 @@ public class LispAddressStringifierTest {
             .setAddress(IPV4)
             .setVirtualNetworkId(new InstanceIdType(VNI)).build();
 
+    // Ipv4Binary
+    private static final byte[] IPV4_BYTES = new byte[]{(byte) 192, (byte) 168, 0, 1};
+    private static final Ipv4AddressBinary IPV4_ADDRESS_BINARY = new Ipv4AddressBinary(IPV4_BYTES);
+    private static final Ipv4Binary IPV4_BINARY = new Ipv4BinaryBuilder().setIpv4Binary(IPV4_ADDRESS_BINARY).build();
+    private static final LispAddress LISP_IPV4_BINARY = new EidBuilder()
+            .setAddress(IPV4_BINARY)
+            .setVirtualNetworkId(new InstanceIdType(VNI)).build();
+
     // Ipv6
     private static final String IPV6_STRING = "1111:2222:3333:4444:5555:6666:7777:8888";
     private static final Ipv6Address IPV6_ADDRESS = new Ipv6Address(IPV6_STRING);
     private static final Ipv6 IPV6 = new Ipv6Builder().setIpv6(new Ipv6Address(IPV6_STRING)).build();
     private static final LispAddress LISP_IPV6 = new EidBuilder().setAddress(IPV6).build();
 
+    // Ipv6Binary
+    private static final byte[] IPV6_BYTES = new byte[]
+        {17, 17, 34, 34, 51, 51, 68, 68, 85, 85, 102, 102, 119, 119, -120, -120};
+    private static final Ipv6AddressBinary IPV6_ADDRESS_BINARY = new Ipv6AddressBinary(IPV6_BYTES);
+    private static final Ipv6Binary IPV6_BINARY = new Ipv6BinaryBuilder().setIpv6Binary(IPV6_ADDRESS_BINARY).build();
+    private static final LispAddress LISP_IPV6_BINARY = new EidBuilder().setAddress(IPV6_BINARY).build();
+
     // Ipv4Prefix
     private static final String PREFIX = "/24";
     private static final String PREFIX_URL = "%2f24";
@@ -124,6 +119,18 @@ public class LispAddressStringifierTest {
             .setIpv6Prefix(new Ipv6Prefix(IPV6_STRING + PREFIX)).build();
     private static final LispAddress LISP_IPV6_PREFIX = new EidBuilder().setAddress(IPV6_PREFIX).build();
 
+    // Ipv4PrefixBinary
+    private static final Ipv4PrefixBinary IPV4_PREFIX_BINARY = new Ipv4PrefixBinaryBuilder()
+            .setIpv4AddressBinary(IPV4_ADDRESS_BINARY)
+            .setIpv4MaskLength((short) 24).build();
+    private static final LispAddress LISP_IPV4_PREFIX_BINARY = new EidBuilder().setAddress(IPV4_PREFIX_BINARY).build();
+
+    // Ipv6PrefixBinary
+    private static final Ipv6PrefixBinary IPV6_PREFIX_BINARY = new Ipv6PrefixBinaryBuilder()
+            .setIpv6AddressBinary(IPV6_ADDRESS_BINARY)
+            .setIpv6MaskLength((short) 24).build();
+    private static final LispAddress LISP_IPV6_PREFIX_BINARY = new EidBuilder().setAddress(IPV6_PREFIX_BINARY).build();
+
     // Mac
     private static final MacAddress MAC_ADDRESS = new MacAddress("01:23:45:67:89:ab");
     private static final Mac MAC = new MacBuilder().setMac(MAC_ADDRESS).build();
@@ -272,6 +279,14 @@ public class LispAddressStringifierTest {
         assertEquals("[" + VNI + "] " + IPV4_STRING, LispAddressStringifier.getString(LISP_IPV4));
     }
 
+    /**
+     * Tests {@link LispAddressStringifier#getString} with Ipv4Binary address type.
+     */
+    @Test
+    public void getStringTest_withIpv4Binary() {
+        assertEquals("[" + VNI + "] " + IPV4_STRING, LispAddressStringifier.getString(LISP_IPV4_BINARY));
+    }
+
     /**
      * Tests {@link LispAddressStringifier#getString} with Ipv4Prefix address type.
      */
@@ -280,6 +295,14 @@ public class LispAddressStringifierTest {
         assertEquals(IPV4_STRING + PREFIX, LispAddressStringifier.getString(LISP_IPV4_PREFIX));
     }
 
+    /**
+     * Tests {@link LispAddressStringifier#getString} with Ipv4PrefixBinary address type.
+     */
+    @Test
+    public void getStringTest_withIpv4PrefixBinary() {
+        assertEquals(IPV4_STRING + PREFIX, LispAddressStringifier.getString(LISP_IPV4_PREFIX_BINARY));
+    }
+
     /**
      * Tests {@link LispAddressStringifier#getString} with Ipv6 address type.
      */
@@ -288,6 +311,14 @@ public class LispAddressStringifierTest {
         assertEquals(IPV6_STRING, LispAddressStringifier.getString(LISP_IPV6));
     }
 
+    /**
+     * Tests {@link LispAddressStringifier#getString} with Ipv6Binary address type.
+     */
+    @Test
+    public void getStringTest_withIpv6Binary() {
+        assertEquals(IPV6_STRING, LispAddressStringifier.getString(LISP_IPV6_BINARY));
+    }
+
     /**
      * Tests {@link LispAddressStringifier#getString} with Ipv6Prefix address type.
      */
@@ -296,6 +327,14 @@ public class LispAddressStringifierTest {
         assertEquals(IPV6_STRING + PREFIX, LispAddressStringifier.getString(LISP_IPV6_PREFIX));
     }
 
+    /**
+     * Tests {@link LispAddressStringifier#getString} with Ipv6PrefixBinary address type.
+     */
+    @Test
+    public void getStringTest_withIpv6PrefixBinary() {
+        assertEquals(IPV6_STRING + PREFIX, LispAddressStringifier.getString(LISP_IPV6_PREFIX_BINARY));
+    }
+
     /**
      * Tests {@link LispAddressStringifier#getString} with Mac address type.
      */
@@ -395,20 +434,20 @@ public class LispAddressStringifierTest {
     private static String getStringFromExplicLocPath() {
         StringBuilder sb = new StringBuilder();
         sb.append("{")
-        .append(IPV4_STRING)
-        .append("|")
-        .append("l")
-        .append("p")
-        .append("s")
+            .append(IPV4_STRING)
+            .append("|")
+            .append("l")
+            .append("p")
+            .append("s")
 
-        .append("->")
+            .append("->")
 
-        .append(IPV6_STRING)
-        .append("|")
-        .append("l")
-        .append("p")
-        .append("s")
-        .append("}");
+            .append(IPV6_STRING)
+            .append("|")
+            .append("l")
+            .append("p")
+            .append("s")
+            .append("}");
 
         return sb.toString();
     }
@@ -427,8 +466,8 @@ public class LispAddressStringifierTest {
     private static String getStringFromSrcDstKey() {
         StringBuilder sb = new StringBuilder();
         sb.append(IPV4_STRING)
-        .append("|")
-        .append(IPV6_STRING);
+            .append("|")
+            .append(IPV6_STRING);
 
         return sb.toString();
     }