Update unit tests
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / multipart / MultipartRequestMeterConfigSerializerTest.java
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestMeterConfigSerializerTest.java
new file mode 100644 (file)
index 0000000..0df02ae
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.impl.protocol.serialization.multipart;
+
+import static org.junit.Assert.assertEquals;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.impl.protocol.serialization.AbstractSerializerTest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+
+public class MultipartRequestMeterConfigSerializerTest extends AbstractSerializerTest {
+    private static final byte PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY = 4;
+    private static final long METER_ID = 42;
+    private static final MultipartRequestMeterConfig BODY = new MultipartRequestMeterConfigBuilder()
+            .setMeterId(new MeterId(METER_ID))
+            .build();
+
+    private MultipartRequestMeterConfigSerializer serializer;
+
+    @Override
+    protected void init() {
+        serializer = getRegistry().getSerializer(new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID,
+                MultipartRequestMeterConfig.class));
+    }
+
+    @Test
+    public void testSerialize() throws Exception {
+        final ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+        serializer.serialize(BODY, out);
+
+        assertEquals(out.readUnsignedInt(), METER_ID);
+        out.skipBytes(PADDING_IN_MULTIPART_REQUEST_METER_CONFIG_BODY);
+        assertEquals(out.readableBytes(), 0);
+    }
+
+}
\ No newline at end of file