Switch common parsers to utils 30/86730/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 5 Jan 2020 21:09:40 +0000 (22:09 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 5 Jan 2020 21:42:22 +0000 (22:42 +0100)
Using subclassing is not that useful, as we want to reserve that
for actually providing baseline behavior. Switch to composition
by making utility methods properly static.

Change-Id: Iec2c26a3642347fac21a3cbd4b382e453e337651
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/ero/EROPathKey128SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/ero/EROPathKey32SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/ero/EROUnnumberedInterfaceSubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/xro/XROPathKey128SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/xro/XROPathKey32SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/xro/XROUnnumberedInterfaceSubobjectParser.java
rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/PathKeyUtils.java [moved from rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonPathKeyParser.java with 95% similarity]
rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/UnnumberedInterfaceSubobjectUtils.java [moved from rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonUnnumberedInterfaceSubobjectParser.java with 83% similarity]
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/PathKeyUtilsTest.java [moved from rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonPathKeyParserTest.java with 83% similarity]
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/UnnumberedInterfaceSubobjectUtilsTest.java [moved from rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CUISubobjectParserTest.java with 81% similarity]

index 190149cd436d6618e539adfc34795e95c945c1fa..89bbfb7231392b78ec163648e3110f1961cfcb3a 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.protocol.rsvp.parser.impl.subobject.ero;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
@@ -19,8 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for { PathKey }.
  */
-public class EROPathKey128SubobjectParser extends CommonPathKeyParser implements EROSubobjectParser {
-
+public class EROPathKey128SubobjectParser  implements EROSubobjectParser {
     public static final int TYPE = 65;
 
     protected static final int PCE128_ID_F_LENGTH = 16;
@@ -29,15 +29,14 @@ public class EROPathKey128SubobjectParser extends CommonPathKeyParser implements
 
     @Override
     public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
         if (buffer.readableBytes() != CONTENT128_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
                 + "Expected: >" + CONTENT128_LENGTH + ".");
         }
-        final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
-        builder.setLoose(loose);
-        builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(parsePathKey(PCE128_ID_F_LENGTH, buffer)).build());
-        return builder.build();
+        return new SubobjectContainerBuilder()
+                .setLoose(loose)
+                .setSubobjectType(new PathKeyCaseBuilder().setPathKey(parsePathKey(PCE128_ID_F_LENGTH, buffer)).build())
+                .build();
     }
 }
index 4e09c0f0e3ccad3aaa9d8550d477635432611214..4373fa49f28c44240dbe001e819266177b849fa8 100644 (file)
@@ -7,13 +7,15 @@
  */
 package org.opendaylight.protocol.rsvp.parser.impl.subobject.ero;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.serializePathKey;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectUtil;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
@@ -22,19 +24,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for {PathKey}.
  */
-public class EROPathKey32SubobjectParser extends CommonPathKeyParser implements EROSubobjectParser,
-    EROSubobjectSerializer {
-
+public class EROPathKey32SubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
     public static final int TYPE = 64;
 
     private static final int PCE_ID_F_LENGTH = 4;
-
     private static final int CONTENT_LENGTH = 2 + PCE_ID_F_LENGTH;
 
     @Override
     public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
                 + "Expected: >" + CONTENT_LENGTH + ".");
@@ -48,9 +46,8 @@ public class EROPathKey32SubobjectParser extends CommonPathKeyParser implements
 
     @Override
     public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
-            "Unknown subobject instance.Passed %s. Needed PathKey.",
-            subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+            "Unknown subobject instance.Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
             .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType())
             .getPathKey();
index 71194ae97efdcf66b3108597ce7f36dc67a0cd54..b2221041cc78b0709ef030d999cb2241ba66e923 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.protocol.rsvp.parser.impl.subobject.ero;
 
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface;
+
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -14,7 +17,6 @@ import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.rsvp.parser.spi.EROSubobjectUtil;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonUnnumberedInterfaceSubobjectParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder;
@@ -22,13 +24,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for {@link UnnumberedCase}.
  */
-public class EROUnnumberedInterfaceSubobjectParser extends CommonUnnumberedInterfaceSubobjectParser implements
-    EROSubobjectParser, EROSubobjectSerializer {
-
+public class EROUnnumberedInterfaceSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
     public static final int TYPE = 4;
 
     private static final int RESERVED = 2;
-
     private static final int CONTENT_LENGTH = 10;
 
     @Override
index f6f86332e83936a1201868563d0cc8b5b37ccb07..77e8a6bc1090930a5e43d132e4e0a55db27b7dc4 100644 (file)
@@ -5,14 +5,14 @@
  * 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.protocol.rsvp.parser.impl.subobject.xro;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
@@ -20,7 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for { PathKey}.
  */
-public class XROPathKey128SubobjectParser extends CommonPathKeyParser implements XROSubobjectParser {
+public class XROPathKey128SubobjectParser implements XROSubobjectParser {
     public static final int TYPE = 65;
 
     protected static final int PCE128_ID_F_LENGTH = 16;
@@ -28,9 +28,9 @@ public class XROPathKey128SubobjectParser extends CommonPathKeyParser implements
     private static final int CONTENT128_LENGTH = 2 + PCE128_ID_F_LENGTH;
 
     @Override
-    public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
-        RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+    public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory)
+            throws RSVPParsingException {
+        checkArgument(buffer != null && buffer.isReadable(),
             "Array of bytes is mandatory. Can't be null or empty.");
         if (buffer.readableBytes() != CONTENT128_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
index baa0f1ec6730417207bf1251f775b0013ac307e3..03cfc159d8151eb0d48ecca511d4dede67dfbd44 100644 (file)
@@ -5,15 +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.protocol.rsvp.parser.impl.subobject.xro;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.parsePathKey;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.PathKeyUtils.serializePathKey;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectSerializer;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonPathKeyParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
@@ -22,18 +23,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for { PathKey}.
  */
-public class XROPathKey32SubobjectParser extends CommonPathKeyParser implements XROSubobjectParser,
-    XROSubobjectSerializer {
+public class XROPathKey32SubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
     public static final int TYPE = 64;
 
     private static final int PCE_ID_F_LENGTH = 4;
-
     private static final int CONTENT_LENGTH = 2 + PCE_ID_F_LENGTH;
 
     @Override
-    public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
-        RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+    public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory)
+            throws RSVPParsingException {
+        checkArgument(buffer != null && buffer.isReadable(),
             "Array of bytes is mandatory. Can't be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
@@ -48,9 +47,8 @@ public class XROPathKey32SubobjectParser extends CommonPathKeyParser implements
 
     @Override
     public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
-            "Unknown subobject instance.Passed %s. Needed PathKey.",
-            subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+            "Unknown subobject instance.Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
             .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType())
             .getPathKey();
index caf37d8039a53518dd0b596ccfb4907ba7e8629d..75c370a0b2348630abf2736f6c2bb6b978ad87c1 100644 (file)
@@ -8,14 +8,14 @@
 package org.opendaylight.protocol.rsvp.parser.impl.subobject.xro;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface;
+import static org.opendaylight.protocol.rsvp.parser.spi.subobjects.UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectSerializer;
-import org.opendaylight.protocol.rsvp.parser.spi.subobjects.CommonUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
@@ -25,8 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 /**
  * Parser for {@link UnnumberedCase}.
  */
-public class XROUnnumberedInterfaceSubobjectParser extends CommonUnnumberedInterfaceSubobjectParser
-        implements XROSubobjectParser, XROSubobjectSerializer {
+public class XROUnnumberedInterfaceSubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
     public static final int TYPE = 4;
 
     private static final int RESERVED = 1;
@@ -43,7 +42,7 @@ public class XROUnnumberedInterfaceSubobjectParser extends CommonUnnumberedInter
         buffer.readerIndex(buffer.readerIndex() + RESERVED);
         return new SubobjectContainerBuilder()
                 .setMandatory(mandatory)
-                .setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()))
+                .setAttribute(Attribute.forValue(buffer.readUnsignedByte()))
                 .setSubobjectType(parseUnnumeredInterface(buffer))
                 .build();
     }
similarity index 95%
rename from rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonPathKeyParser.java
rename to rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/PathKeyUtils.java
index 0597a9c9a7b59af686f708a8dafc82c1f1fcd113..fc613383dbcbd52d9d45195002f312bb4ad2d0fd 100644 (file)
@@ -17,9 +17,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
 
-public class CommonPathKeyParser {
-    protected CommonPathKeyParser() {
-
+public final class PathKeyUtils {
+    private PathKeyUtils() {
+        // Hidden on purpose
     }
 
     public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
@@ -14,12 +14,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
 
-public class CommonUnnumberedInterfaceSubobjectParser {
-    protected CommonUnnumberedInterfaceSubobjectParser() {
-
+public final class UnnumberedInterfaceSubobjectUtils {
+    private UnnumberedInterfaceSubobjectUtils() {
+        // Hidden on purpose
     }
 
-    protected static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
+    public static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
         return new UnnumberedCaseBuilder()
                 .setUnnumbered(new UnnumberedBuilder()
                     .setRouterId(ByteBufUtils.readUint32(buffer))
@@ -28,7 +28,7 @@ public class CommonUnnumberedInterfaceSubobjectParser {
                 .build();
     }
 
-    protected static void serializeUnnumeredInterface(final Unnumbered unnumbered, final ByteBuf body) {
+    public static void serializeUnnumeredInterface(final Unnumbered unnumbered, final ByteBuf body) {
         ByteBufUtils.writeMandatory(body, unnumbered.getRouterId(), "RouterId");
         ByteBufUtils.writeMandatory(body, unnumbered.getInterfaceId(), "InterfaceId");
     }
similarity index 83%
rename from rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonPathKeyParserTest.java
rename to rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/PathKeyUtilsTest.java
index f7cc950b033ad819bd9777692b53428f479191e7..72f99f1ba8e62e584bf6d503294bc0fe6b725a38 100644 (file)
@@ -20,8 +20,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
 import org.opendaylight.yangtools.yang.common.Uint16;
 
-public class CommonPathKeyParserTest {
-    private final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5};
+public class PathKeyUtilsTest {
+    private final byte[] bytes = new byte[] { 0, 1, 2, 3, 4, 5 };
     private PathKey key1;
     private PathKey key2;
     private PathKey key3;
@@ -40,22 +40,22 @@ public class CommonPathKeyParserTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testSerializationExcption1() {
-        CommonPathKeyParser.serializePathKey(this.key1);
+        PathKeyUtils.serializePathKey(this.key1);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testSerializationExcption2() {
-        CommonPathKeyParser.serializePathKey(this.key2);
+        PathKeyUtils.serializePathKey(this.key2);
     }
 
     @Test
     public void testSerialization() {
-        final ByteBuf output = CommonPathKeyParser.serializePathKey(this.key3);
+        final ByteBuf output = PathKeyUtils.serializePathKey(this.key3);
         assertArrayEquals(this.bytes, ByteArray.readAllBytes(output));
     }
 
     @Test
     public void testParsing() {
-        assertEquals(this.key3, CommonPathKeyParser.parsePathKey(4, Unpooled.copiedBuffer(this.bytes)));
+        assertEquals(this.key3, PathKeyUtils.parsePathKey(4, Unpooled.copiedBuffer(this.bytes)));
     }
 }
similarity index 81%
rename from rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CUISubobjectParserTest.java
rename to rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/UnnumberedInterfaceSubobjectUtilsTest.java
index 96212e95106f9fe5e1b28d8762ff0ae7f62c22f2..e15d054c197f1a3ecc568448bf71482e64d56cbf 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
 import org.opendaylight.yangtools.yang.common.Uint32;
 
-public class CUISubobjectParserTest {
+public class UnnumberedInterfaceSubobjectUtilsTest {
     private final Uint32 routerId = Uint32.valueOf(3735928559L);
     private final Uint32 interfaceId = Uint32.valueOf(3736059631L);
     private final Unnumbered unnumbered1 = new UnnumberedBuilder().setRouterId((Uint32) null).build();
@@ -30,23 +30,22 @@ public class CUISubobjectParserTest {
         final ByteBuf input = Unpooled.buffer(8);
         input.writeInt(this.routerId.intValue());
         input.writeInt(this.interfaceId.intValue());
-        final UnnumberedCase output = CommonUnnumberedInterfaceSubobjectParser.parseUnnumeredInterface(input);
+        final UnnumberedCase output = UnnumberedInterfaceSubobjectUtils.parseUnnumeredInterface(input);
         assertEquals(this.routerId, output.getUnnumbered().getRouterId());
         assertEquals(this.interfaceId, output.getUnnumbered().getInterfaceId());
 
         final ByteBuf bytebuf = Unpooled.buffer(8);
-        CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(output.getUnnumbered(), bytebuf);
+        UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(output.getUnnumbered(), bytebuf);
         assertArrayEquals(input.array(), bytebuf.array());
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testException1() {
-        CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(this.unnumbered1, Unpooled.EMPTY_BUFFER);
+        UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(this.unnumbered1, Unpooled.EMPTY_BUFFER);
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testException2() {
-        CommonUnnumberedInterfaceSubobjectParser.serializeUnnumeredInterface(this.unnumbered2, Unpooled.buffer(4));
+        UnnumberedInterfaceSubobjectUtils.serializeUnnumeredInterface(this.unnumbered2, Unpooled.buffer(4));
     }
-
 }