Make BitsTypeDefinition.Bit.position() return Uint32 08/88808/5
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 31 Mar 2020 13:50:42 +0000 (15:50 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 16 Apr 2020 19:14:33 +0000 (21:14 +0200)
We seem to be brdiging back and forth between long and Uint32,
as PositionEffectiveStatement is defined in terms of Uint32. Bite
the bullet and convert Bit, too, removing a number of impossible
cases.

JIRA: YANGTOOLS-1072
Change-Id: I16a38b2780ca25b76eb8cc93c66546f9edb9d8b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
16 files changed:
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/BitsCodecStringTest.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/type/BitsTypeDefinition.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitBuilder.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/type/BitsTypeBuilder.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/BitsTypeTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/BitImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/type/TypeTest.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/bit/BitEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsSpecificationEffectiveStatement.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsTypeEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/EffectiveTypeUtil.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6887Test.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveStatementTypeTest.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TypesResolutionTest.java

index 6aa528d7ca7e72a3f2e50d4b69d6326502dfad9b..840be862baf2e67585e9cdc64bae23b4487f82c7 100644 (file)
@@ -17,6 +17,7 @@ import static org.mockito.Mockito.when;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collections;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.codec.BitsCodec;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
@@ -37,7 +38,7 @@ public class BitsCodecStringTest {
         for (String bit : bits) {
             BitsTypeDefinition.Bit mockBit = mock(BitsTypeDefinition.Bit.class);
             when(mockBit.getName()).thenReturn(bit);
-            when(mockBit.getPosition()).thenReturn(pos);
+            when(mockBit.getPosition()).thenReturn(Uint32.valueOf(pos));
             b.addBit(mockBit);
             ++pos;
         }
index 862129c9d6a25290fb43385379556dbad1536269..2591d0666207e82a693ebaf0e45225508dac0bdc 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Collection;
 import java.util.Objects;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
@@ -62,6 +63,6 @@ public interface BitsTypeDefinition extends TypeDefinition<BitsTypeDefinition> {
          *
          * @return The position value of bit in range from 0 to 4294967295.
          */
-        long getPosition();
+        @NonNull Uint32 getPosition();
     }
 }
index cd33befaf146a491e550b44d5ed25a0fb4770a6e..2ec0b43eeb429afd86f23b6918fec4a2e03d2068 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.concepts.Mutable;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
@@ -26,19 +27,19 @@ import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 @Beta
 public final class BitBuilder implements Builder<Bit>, Mutable {
     private final String name;
-    private final long position;
+    private final Uint32 position;
 
     private ImmutableList<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.of();
     private Status status = Status.CURRENT;
     private String description;
     private String reference;
 
-    private BitBuilder(final String name, final long position) {
+    private BitBuilder(final String name, final Uint32 position) {
         this.name = requireNonNull(name);
-        this.position = position;
+        this.position = requireNonNull(position);
     }
 
-    public static BitBuilder create(final String name, final long position) {
+    public static BitBuilder create(final String name, final Uint32 position) {
         return new BitBuilder(name, position);
     }
 
index ed0ed5659f9cdda6ad8c5883ef2637ba9d3338b8..0a7f3092741b9a869f70df6b0d86d3c2ccc64932 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.model.util.type;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ImmutableList;
@@ -16,6 +15,7 @@ import java.util.List;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
@@ -26,13 +26,12 @@ final class BitImpl implements Bit, Immutable {
     private final String description;
     private final String reference;
     private final @NonNull Status status;
-    private final long position;
+    private final @NonNull Uint32 position;
 
-    BitImpl(final String name, final long position, final String description,
+    BitImpl(final String name, final Uint32 position, final String description,
             final String reference, final Status status, final List<UnknownSchemaNode> unknownNodes) {
         this.name = requireNonNull(name);
-        checkArgument(position >= 0L && position <= 4294967295L, "Invalid position %s", position);
-        this.position = position;
+        this.position = requireNonNull(position);
         this.description = description;
         this.reference = reference;
         this.status = requireNonNull(status);
@@ -60,7 +59,7 @@ final class BitImpl implements Bit, Immutable {
     }
 
     @Override
-    public long getPosition() {
+    public Uint32 getPosition() {
         return position;
     }
 
@@ -71,7 +70,7 @@ final class BitImpl implements Bit, Immutable {
 
     @Override
     public int hashCode() {
-        return 31 * name.hashCode() + Long.hashCode(position);
+        return 31 * name.hashCode() + position.hashCode();
     }
 
     @Override
index 11e0bedef887577c5cb5c9372e7e5ae09605fb61..9cfd85470a6e55138607c5efea228330f750d62c 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableMap.Builder;
 import java.util.Map;
 import java.util.TreeMap;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
@@ -61,7 +62,7 @@ public final class BitsTypeBuilder extends AbstractRestrictedTypeBuilder<BitsTyp
     @Override
     public BitsTypeDefinition buildType() {
         final Map<String, Bit> map = builder.build();
-        final Map<Long, Bit> positionMap = new TreeMap<>();
+        final Map<Uint32, Bit> positionMap = new TreeMap<>();
 
         for (Bit b : map.values()) {
             final Bit conflict = positionMap.put(b.getPosition(), b);
index f30c3d81bf7347c7de4550cba5e48bd6ff90973b..3e883fd3812dfeb5cbbd3dcdd2c6c8ad61acd6bd 100644 (file)
@@ -20,6 +20,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
@@ -33,7 +34,7 @@ public class BitsTypeTest {
     @Test
     public void canCreateBitsType() {
         doReturn("test").when(bit).getName();
-        doReturn(0L).when(bit).getPosition();
+        doReturn(Uint32.ZERO).when(bit).getPosition();
         doReturn("toString").when(bit).toString();
 
         QName qname = QName.create("namespace", "localname");
index da931fbf6aa762fb5d37238c3c6b014d1cc068f2..e3e0fe0ef9e75c6b14b3583ae33231ca89f8aa9f 100644 (file)
@@ -14,9 +14,11 @@ import static org.junit.Assert.assertFalse;
 import java.net.URISyntaxException;
 import java.util.Optional;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.Status;
 
 public class BitImplTest {
+    private static final Uint32 FIFTY_FIVE = Uint32.valueOf(55);
 
     @Test
     // We're testing equals()
@@ -25,30 +27,30 @@ public class BitImplTest {
 
         // hashCode method test
 
-        BitImpl biA = new BitImpl("someNameA2", 55L, "description", "reference", Status.CURRENT, emptyList());
+        BitImpl biA = new BitImpl("someNameA2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
 
         assertEquals("biA should equals to itsefl", biA, biA);
         assertFalse("biA shouldn't equal to null", biA.equals(null));
         assertFalse("biA shouldn't equal to object of other type", biA.equals("str"));
 
          // // test schemaPath
-        biA = new BitImpl("someNameA2", 55L, "description", "reference", Status.CURRENT, emptyList());
-        BitImpl biB = new BitImpl("someNameB2", 55L, "description", "reference", Status.CURRENT, emptyList());
+        biA = new BitImpl("someNameA2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
+        BitImpl biB = new BitImpl("someNameB2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
         assertFalse("biA shouldn't equal to biB", biA.equals(biB));
 
-        biA = new BitImpl("someNameB2", 55L, "description", "reference", Status.CURRENT, emptyList());
-        biB = new BitImpl("someNameB2", 55L, "description", "reference", Status.CURRENT, emptyList());
+        biA = new BitImpl("someNameB2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
+        biB = new BitImpl("someNameB2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
         assertEquals("biA should equal to biB", biA, biB);
 
-        biA = new BitImpl("someNameA2", 55L, "description", "reference", Status.CURRENT, emptyList());
-        biB = new BitImpl("someNameB2", 55L, "description", "reference", Status.CURRENT, emptyList());
+        biA = new BitImpl("someNameA2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
+        biB = new BitImpl("someNameB2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
         assertFalse("biA shouldn't equal to biB", biA.equals(biB));
 
-        biA = new BitImpl("someNameA2", 55L, "description", "reference", Status.CURRENT, emptyList());
-        biB = new BitImpl("someNameA2", 55L, "description", "reference", Status.CURRENT, emptyList());
+        biA = new BitImpl("someNameA2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
+        biB = new BitImpl("someNameA2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
         assertEquals("biA should equal to biB", biA, biB);
 
-        biA = new BitImpl("someNameA2", 55L, "description", "reference", Status.CURRENT, emptyList());
+        biA = new BitImpl("someNameA2", FIFTY_FIVE, "description", "reference", Status.CURRENT, emptyList());
 
         // test of getter methods
         assertEquals("Incorrect value for qname.", "someNameA2", biA.getName());
index 011536f7efc0b8561e1811b80ce7ca0c59bfe0f7..8268aa269b94526aa7eadd7516260fa55d6452d1 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.PathExpression;
@@ -56,8 +57,10 @@ public class TypeTest {
     private static final QName Q_NAME = QName.create("test.namespace", "2016-01-01", "test-name");
     private static final SchemaPath SCHEMA_PATH = SchemaPath.create(true, Q_NAME);
     private static final PathExpression REVISION_AWARE_XPATH = new PathExpressionImpl("/test", true);
-    private static final Bit BIT_A = BitBuilder.create(Q_NAME.getLocalName(), 55L).setDescription("description")
-            .setReference("reference").build();
+    private static final Bit BIT_A = BitBuilder.create(Q_NAME.getLocalName(), Uint32.valueOf(55L))
+        .setDescription("description")
+        .setReference("reference")
+        .build();
     private static final Optional<String> ABSENT = Optional.empty();
 
     @Test
@@ -456,9 +459,10 @@ public class TypeTest {
 
     @Test(expected = InvalidBitDefinitionException.class)
     public void invalidBitDefinitionExceptionTest() {
-        final BitsTypeBuilder bitsTypeBuilder = BaseTypes.bitsTypeBuilder(SCHEMA_PATH);
-        bitsTypeBuilder.addBit(BIT_A);
-        bitsTypeBuilder.addBit(BitBuilder.create("test-name-1", 55L).build());
+        final BitsTypeBuilder bitsTypeBuilder = BaseTypes.bitsTypeBuilder(SCHEMA_PATH)
+                .addBit(BIT_A)
+                .addBit(BitBuilder.create("test-name-1", Uint32.valueOf(55)).build());
+
         bitsTypeBuilder.build();
     }
 
index 4b01974abffe523e6084cbc8fc2dacfc94fcf3c5..ef36864004c495e009ae14a2be22f5c894c30a7c 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 final class BitEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<String, BitStatement>
         implements BitEffectiveStatement {
-
     BitEffectiveStatementImpl(final StmtContext<String, BitStatement, ?> ctx) {
         super(ctx);
     }
index c91af1660bc2b326e72009e495ac1e98a8a2c51b..4e1c81719f59c0eb655a92956f8d510dd633c9cf 100644 (file)
@@ -33,30 +33,27 @@ final class BitsSpecificationEffectiveStatement extends DeclaredEffectiveStateme
         super(ctx);
 
         final BitsTypeBuilder builder = BaseTypes.bitsTypeBuilder(ctx.getSchemaPath().get());
-        Long highestPosition = null;
+        Uint32 highestPosition = null;
         for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
             if (stmt instanceof BitEffectiveStatement) {
                 final BitEffectiveStatement bitSubStmt = (BitEffectiveStatement) stmt;
 
                 final Optional<Uint32> declaredPosition = bitSubStmt.getDeclaredPosition();
-                final long effectivePos;
+                final Uint32 effectivePos;
                 if (declaredPosition.isEmpty()) {
                     if (highestPosition != null) {
-                        SourceException.throwIf(highestPosition == 4294967295L, ctx.getStatementSourceReference(),
-                                "Bit %s must have a position statement", bitSubStmt);
-                        effectivePos = highestPosition + 1;
+                        SourceException.throwIf(Uint32.MAX_VALUE.equals(highestPosition),
+                            ctx.getStatementSourceReference(), "Bit %s must have a position statement", bitSubStmt);
+                        effectivePos = Uint32.fromIntBits(highestPosition.intValue() + 1);
                     } else {
-                        effectivePos = 0L;
+                        effectivePos = Uint32.ZERO;
                     }
                 } else {
-                    effectivePos = declaredPosition.get().toJava();
+                    effectivePos = declaredPosition.get();
                 }
 
                 final Bit bit = EffectiveTypeUtil.buildBit(bitSubStmt, effectivePos);
-                SourceException.throwIf(bit.getPosition() < 0L && bit.getPosition() > 4294967295L,
-                        ctx.getStatementSourceReference(), "Bit %s has illegal position", bit);
-
-                if (highestPosition == null || highestPosition < bit.getPosition()) {
+                if (highestPosition == null || highestPosition.compareTo(bit.getPosition()) < 0) {
                     highestPosition = bit.getPosition();
                 }
 
index 1b2297b29184326a002666d674c680414b15fbec..e0c83b3c9915073cbf40a19ef51fad3e60b20596 100644 (file)
@@ -45,11 +45,11 @@ final class BitsTypeEffectiveStatementImpl extends DeclaredEffectiveStatementBas
 
                 // FIXME: this looks like a duplicate of BitsSpecificationEffectiveStatement
                 final Optional<Uint32> declared = bitSubStmt.getDeclaredPosition();
-                final long effectivePos;
+                final Uint32 effectivePos;
                 if (declared.isEmpty()) {
                     effectivePos = getBaseTypeBitPosition(bitSubStmt.argument(), baseType, ctx);
                 } else {
-                    effectivePos = declared.get().toJava();
+                    effectivePos = declared.get();
                 }
 
                 builder.addBit(EffectiveTypeUtil.buildBit(bitSubStmt, effectivePos));
@@ -61,7 +61,7 @@ final class BitsTypeEffectiveStatementImpl extends DeclaredEffectiveStatementBas
         typeDefinition = builder.build();
     }
 
-    private static long getBaseTypeBitPosition(final String bitName, final BitsTypeDefinition baseType,
+    private static Uint32 getBaseTypeBitPosition(final String bitName, final BitsTypeDefinition baseType,
             final StmtContext<?, ?, ?> ctx) {
         for (Bit baseTypeBit : baseType.getBits()) {
             if (bitName.equals(baseTypeBit.getName())) {
index 5e3cf6dab26b94cd7eb64fa0590885261bf16645..1eba0f84527e016cf4f5b808fd31d801ead06db3 100644 (file)
@@ -11,6 +11,7 @@ import static com.google.common.base.Verify.verify;
 
 import com.google.common.annotations.Beta;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
 import org.opendaylight.yangtools.yang.model.api.stmt.BitEffectiveStatement;
@@ -26,7 +27,7 @@ final class EffectiveTypeUtil {
         // Hidden on purpose
     }
 
-    static @NonNull Bit buildBit(final @NonNull BitEffectiveStatement stmt, final long effectivePos) {
+    static @NonNull Bit buildBit(final @NonNull BitEffectiveStatement stmt, final Uint32 effectivePos) {
         verify(stmt instanceof DocumentedNode.WithStatus);
         final DocumentedNode.WithStatus bit = (WithStatus) stmt;
 
index 445707034f0a92845897491129d51c59c5777e85..fc159f32ffe1eab2a0da5626dec2118c91ea64f2 100644 (file)
@@ -18,6 +18,7 @@ import java.util.List;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -302,7 +303,7 @@ public class Bug6887Test {
     }
 
     private static Bit createBit(final String name, final long position) {
-        return BitBuilder.create(name, position).build();
+        return BitBuilder.create(name, Uint32.valueOf(position)).build();
     }
 
     private static void assertContainsBits(final Collection<? extends Bit> bitList, final Bit... bits) {
index 12277784120f1cedf62e8794cd150c7ccf35b158..f7ee7b77c9b487046d0c4e0330231ffbaf250283 100644 (file)
@@ -15,6 +15,7 @@ import static org.junit.Assert.fail;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -76,19 +77,19 @@ public class Bug6316Test {
             final String name = bit.getName();
             switch (name) {
                 case "zero":
-                    assertEquals(0, bit.getPosition());
+                    assertEquals(Uint32.ZERO, bit.getPosition());
                     break;
                 case "twenty":
-                    assertEquals(20, bit.getPosition());
+                    assertEquals(Uint32.valueOf(20), bit.getPosition());
                     break;
                 case "twenty-one":
-                    assertEquals(21, bit.getPosition());
+                    assertEquals(Uint32.valueOf(21), bit.getPosition());
                     break;
                 case "two":
-                    assertEquals(2, bit.getPosition());
+                    assertEquals(Uint32.TWO, bit.getPosition());
                     break;
                 case "twenty-two":
-                    assertEquals(22, bit.getPosition());
+                    assertEquals(Uint32.valueOf(22), bit.getPosition());
                     break;
                 default:
                     fail("Unexpected bit name.");
index b6a53c7dda32ac90adc4ed01835882320413473c..ea7d2cbc14b1910a86205222d863a3939602b433 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -129,7 +130,7 @@ public class EffectiveStatementTypeTest {
         assertFalse(bitEff.equals(bitEffSecond));
         assertNotNull(bitEff.toString());
         assertEquals("one", bitEff.getName());
-        assertEquals(0, bitEff.getPosition());
+        assertEquals(Uint32.ZERO, bitEff.getPosition());
     }
 
     @Test
index 082ed5a11f7d6a0e8ad2547b3afe56f327ebaf31..aee1408401aa2e1e2ef655db965366fbf53be0e3 100644 (file)
@@ -25,6 +25,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -230,15 +231,15 @@ public class TypesResolutionTest {
 
         Bit bit1 = bits.next();
         assertEquals("disable-nagle", bit1.getName());
-        assertEquals(0L, bit1.getPosition());
+        assertEquals(Uint32.ZERO, bit1.getPosition());
 
         Bit bit2 = bits.next();
         assertEquals("auto-sense-speed", bit2.getName());
-        assertEquals(1L, bit2.getPosition());
+        assertEquals(Uint32.ONE, bit2.getPosition());
 
         Bit bit3 = bits.next();
         assertEquals("only-10-Mb", bit3.getName());
-        assertEquals(2L, bit3.getPosition());
+        assertEquals(Uint32.TWO, bit3.getPosition());
 
         assertFalse(bits.hasNext());
     }
@@ -254,23 +255,23 @@ public class TypesResolutionTest {
 
         Bit bit0 = bits.next();
         assertEquals("create", bit0.getName());
-        assertEquals(0L, bit0.getPosition());
+        assertEquals(Uint32.ZERO, bit0.getPosition());
 
         Bit bit1 = bits.next();
         assertEquals("delete", bit1.getName());
-        assertEquals(365L, bit1.getPosition());
+        assertEquals(Uint32.valueOf(365), bit1.getPosition());
 
         Bit bit2 = bits.next();
         assertEquals("read", bit2.getName());
-        assertEquals(500L, bit2.getPosition());
+        assertEquals(Uint32.valueOf(500), bit2.getPosition());
 
         Bit bit3 = bits.next();
         assertEquals("update", bit3.getName());
-        assertEquals(501L, bit3.getPosition());
+        assertEquals(Uint32.valueOf(501), bit3.getPosition());
 
         Bit bit4 = bits.next();
         assertEquals("exec", bit4.getName());
-        assertEquals(502L, bit4.getPosition());
+        assertEquals(Uint32.valueOf(502), bit4.getPosition());
 
         assertFalse(bits.hasNext());
     }