UT added for Pcep TLVs

Change-Id: Ic231a2af9dafa2a5ee235808066aa531fea95242
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
index df8858e..bc12809 100644
--- a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
@@ -40,6 +40,17 @@
         this.remoteIpv4Addr = remoteIpv4;

     }

 

+    /**

+     * Returns Object of Pcep nai Ipv4 Adjacency.

+     *

+     * @param localIpv4Addr local ipv4 address

+     * @param remoteIpv4Addr remote ipv4 address

+     * @return Object of Pcep nai Ipv4 Adjacency

+     */

+    public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) {

+        return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr);

+    }

+

     @Override

     public byte getType() {

         return ST_TYPE;

diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
index a181a34..ae42d11 100644
--- a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
@@ -39,6 +39,16 @@
         this.ipv6NodeId = value;

     }

 

+    /**

+     * Return object of Pcep Nai Ipv6 Node ID.

+     *

+     * @param ipv6NodeId Ipv6 node ID.

+     * @return object of Pcep Nai Ipv6 Node ID.

+     */

+    public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) {

+        return new PcepNaiIpv6NodeId(ipv6NodeId);

+    }

+

     @Override

     public byte getType() {

         return ST_TYPE;

diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java
new file mode 100644
index 0000000..53f75ec
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java
@@ -0,0 +1,39 @@
+/*

+ * Copyright 2015 Open Networking Laboratory

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+package org.onosproject.pcepio;

+

+import org.junit.Test;

+import org.onosproject.pcepio.types.NexthopIPv4addressTlv;

+

+import com.google.common.testing.EqualsTester;

+

+/**

+ * Equality test for NexthopIPv4addressTlv.

+ */

+public class NexthopIPv4addressTlvTest {

+

+    private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A);

+    private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A);

+    private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B);

+

+    @Test

+    public void basics() {

+        new EqualsTester()

+        .addEqualityGroup(tlv1, sameAsTlv1)

+        .addEqualityGroup(tlv2)

+        .testEquals();

+    }

+}

diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.java
new file mode 100644
index 0000000..a543d65
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.NexthopIPv6addressTlv;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for NexthopIPv6addressTlv.
+ */
+public class NexthopIPv6addressTlvTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00 };
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+            (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+    private final NexthopIPv6addressTlv tlv1 = NexthopIPv6addressTlv.of(b1);
+    private final NexthopIPv6addressTlv sameAsTlv1 = NexthopIPv6addressTlv.of(b1);
+    private final NexthopIPv6addressTlv tlv2 = NexthopIPv6addressTlv.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java
new file mode 100644
index 0000000..36a610b
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java
@@ -0,0 +1,39 @@
+/*

+ * Copyright 2015 Open Networking Laboratory

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+package org.onosproject.pcepio;

+

+import org.junit.Test;

+import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv;

+

+import com.google.common.testing.EqualsTester;

+

+/**

+ * Equality test for NexthopUnnumberedIPv4IDTlv.

+ */

+public class NexthopUnnumberedIPv4IDTlvTest {

+

+    private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);

+    private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);

+    private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B);

+

+    @Test

+    public void basics() {

+        new EqualsTester()

+        .addEqualityGroup(tlv1, sameAsTlv1)

+        .addEqualityGroup(tlv2)

+        .testEquals();

+    }

+}

diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java
new file mode 100644
index 0000000..2229c49
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java
@@ -0,0 +1,39 @@
+/*

+ * Copyright 2015 Open Networking Laboratory

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+package org.onosproject.pcepio;

+

+import org.junit.Test;

+import org.onosproject.pcepio.types.PathKeySubObject;

+

+import com.google.common.testing.EqualsTester;

+

+/**

+ * Test of the PathKeySubObject.

+ */

+public class PathKeySubObjectTest {

+

+    private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A);

+    private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A);

+    private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B);

+

+    @Test

+    public void basics() {

+        new EqualsTester()

+        .addEqualityGroup(tlv1, sameAsTlv1)

+        .addEqualityGroup(tlv2)

+        .testEquals();

+    }

+}

diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java
new file mode 100644
index 0000000..390f573
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for PcepNaiIpv4Adjacency.
+ */
+public class PcepNaiIpv4AdjacencyTest {
+
+    private final PcepNaiIpv4Adjacency obj1 = PcepNaiIpv4Adjacency.of(2, 16);
+    private final PcepNaiIpv4Adjacency sameAsObj1 = PcepNaiIpv4Adjacency.of(2, 16);
+    private final PcepNaiIpv4Adjacency obj2 = PcepNaiIpv4Adjacency.of(3, 16);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(obj1, sameAsObj1).addEqualityGroup(obj2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java
new file mode 100644
index 0000000..bf45894
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.PcepNaiIpv6NodeId;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for PcepNaiIpv6NodeId.
+ */
+public class PcepNaiIpv6NodeIdTest {
+
+    private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+                                          (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02,
+                                          0x00, 0x00 };
+    private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+                                          (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02,
+                                          0x00, 0x00 };
+
+    private final PcepNaiIpv6NodeId tlv1 = PcepNaiIpv6NodeId.of(b1);
+    private final PcepNaiIpv6NodeId sameAsTlv1 = PcepNaiIpv6NodeId.of(b1);
+    private final PcepNaiIpv6NodeId tlv2 = PcepNaiIpv6NodeId.of(b2);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+    }
+
+}
diff --git a/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTLVTest.java b/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTLVTest.java
new file mode 100644
index 0000000..e2d1e32
--- /dev/null
+++ b/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTLVTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pcepio;
+
+import org.junit.Test;
+import org.onosproject.pcepio.types.RoutingUniverseTLV;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Equality test for RoutingUniverseTlv.
+ */
+public class RoutingUniverseTLVTest {
+
+    private final RoutingUniverseTLV tlv1 = RoutingUniverseTLV.of(2);
+    private final RoutingUniverseTLV tlv2 = RoutingUniverseTLV.of(2);
+    private final RoutingUniverseTLV tlv3 = RoutingUniverseTLV.of(3);
+
+    @Test
+    public void basics() {
+        new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+    }
+}