Bump upstreams for 2022.09 Chlorine
[openflowplugin.git] / extension / openflowjava-extension-nicira / src / test / java / org / opendaylight / openflowjava / nx / codec / match / TunIdCodecTest.java
index e1802ab3b9509bb2cf38ed1f8760d8b8242ed4b5..973096dabe9601224f74b39f9d314d7ea714ae5b 100644 (file)
@@ -1,11 +1,10 @@
-/**
+/*
  * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowjava.nx.codec.match;
 
 import static org.junit.Assert.assertEquals;
@@ -13,32 +12,26 @@ import static org.junit.Assert.assertEquals;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufAllocator;
 import java.math.BigInteger;
-import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.TunIdCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.aug.nx.match.TunIdCaseValueBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.id.grouping.TunIdValuesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIdCaseValue;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIdCaseValueBuilder;
+import org.opendaylight.yangtools.yang.common.Uint64;
 
 public class TunIdCodecTest {
+    private final ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
+    private final TunIdCodec tunIdCodec = new TunIdCodec();
 
-    TunIdCodec tunIdCodec;
-    ByteBuf buffer;
-    MatchEntry input;
+    private MatchEntry input;
 
     private static final int VALUE_LENGTH = 8;
     private static final int NXM_FIELD_CODE = 16;
 
-    @Before
-    public void setUp() {
-        tunIdCodec = new TunIdCodec();
-        buffer = ByteBufAllocator.DEFAULT.buffer();
-    }
-
     @Test
     public void serializeTest() {
         input = createMatchEntry();
@@ -58,41 +51,37 @@ public class TunIdCodecTest {
 
         input = tunIdCodec.deserialize(buffer);
 
-        TunIdCaseValue result = ((TunIdCaseValue) input.getMatchEntryValue());
+        final TunIdCaseValue result = (TunIdCaseValue) input.getMatchEntryValue();
 
-        assertEquals(Nxm1Class.class, input.getOxmClass());
-        assertEquals(NxmNxTunId.class, input.getOxmMatchField());
-        assertEquals(false, input.isHasMask());
+        assertEquals(Nxm1Class.VALUE, input.getOxmClass());
+        assertEquals(NxmNxTunId.VALUE, input.getOxmMatchField());
+        assertEquals(false, input.getHasMask());
         assertEquals(0, result.getTunIdValues().getValue().longValue());
     }
 
-
-
-    private MatchEntry createMatchEntry() {
+    private static MatchEntry createMatchEntry() {
         MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
-        TunIdCaseValueBuilder caseBuilder = new TunIdCaseValueBuilder();
-        TunIdValuesBuilder valuesBuilder = new TunIdValuesBuilder();
+        final TunIdCaseValueBuilder caseBuilder = new TunIdCaseValueBuilder();
+        final TunIdValuesBuilder valuesBuilder = new TunIdValuesBuilder();
 
-        matchEntryBuilder.setOxmClass(Nxm1Class.class);
-        matchEntryBuilder.setOxmMatchField(NxmNxTunId.class);
+        matchEntryBuilder.setOxmClass(Nxm1Class.VALUE);
+        matchEntryBuilder.setOxmMatchField(NxmNxTunId.VALUE);
         matchEntryBuilder.setHasMask(false);
 
-        byte[] value = new byte[VALUE_LENGTH];
-        valuesBuilder.setValue(new BigInteger(value));
+        valuesBuilder.setValue(Uint64.ZERO);
 
         caseBuilder.setTunIdValues(valuesBuilder.build());
         matchEntryBuilder.setMatchEntryValue(caseBuilder.build());
         return matchEntryBuilder.build();
     }
 
-    private void createBuffer(ByteBuf message) {
+    private static void createBuffer(final ByteBuf message) {
         message.writeShort(OxmMatchConstants.NXM_1_CLASS);
 
-        int fieldMask = (NXM_FIELD_CODE << 1);
+        int fieldMask = NXM_FIELD_CODE << 1;
         message.writeByte(fieldMask);
         message.writeByte(VALUE_LENGTH);
         byte[] value = new byte[VALUE_LENGTH];
         message.writeLong(new BigInteger(value).longValue());
     }
-
-}
\ No newline at end of file
+}