Migrate yang-data-impl to JUnit5 97/106897/7
authormatus.matok <matus.matok@pantheon.tech>
Thu, 13 Jul 2023 07:37:27 +0000 (09:37 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 18 Oct 2023 07:28:39 +0000 (09:28 +0200)
Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks. Manually corrected variable modifiers,
including migration to 'var'.

JIRA: YANGTOOLS-1521
Change-Id: Iecffb046c782ec732da51d9d92738d3bfebf5ef4
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
29 files changed:
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/BinaryCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/BitsCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/BooleanCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/DecimalCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/EmptyCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/EnumCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Int16CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Int32CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Int64CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Int8CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/StringCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/StringPatternCheckingCodecTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/TypeDefinitionAwareCodecTestHelper.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Uint16CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Uint32CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Uint64CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/Uint8CodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/UnionCodecStringTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/YT1097Test.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/YT1437Test.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codec/YT1442Test.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/BuilderTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/ImmutableNormalizedNodeStreamWriterTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedNodeUtilsTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/OrderingEqualityTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/AbstractImmutableNormalizedValueAttrNodeTest.java
data/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/YT1417Test.java

index b147c9b2687e26c97ebfa9deb31097a249cc90b8..101fa323181c4ce21588768c65ea405452b2c828 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.Base64;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.BinaryCodec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
@@ -21,20 +20,20 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class BinaryCodecStringTest {
+class BinaryCodecStringTest {
     private static final byte[] FOUR_ELEMENTS = { 1, 2, 3, 4 };
 
-    @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        BinaryCodec<String> codec = getCodec(BaseTypes.binaryType(), BinaryCodec.class);
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.binaryType(), BinaryCodec.class);
         assertEquals(Base64.getEncoder().encodeToString(FOUR_ELEMENTS), codec.serialize(FOUR_ELEMENTS));
     }
 
-    @SuppressWarnings("unchecked")
     @Test
-    public void testDererialize() {
-        BinaryCodec<String> codec = getCodec(BaseTypes.binaryType(), BinaryCodec.class);
+    void testDererialize() {
+        @SuppressWarnings("unchecked")
+        final var codec = (BinaryCodec<String>)
+            TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.binaryType(), BinaryCodec.class);
         assertArrayEquals(FOUR_ELEMENTS, codec.deserialize(Base64.getEncoder().encodeToString(FOUR_ELEMENTS)));
     }
 }
index 444b21ef3d422a8b2d7658966144fc764b5bb4c0..f377b3bbaed6b236ed92ae3488d6ccce3ce6b180 100644 (file)
@@ -7,34 +7,32 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import com.google.common.collect.ImmutableSet;
-import java.util.Collections;
-import org.junit.Test;
+import java.util.Set;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.codec.BitsCodec;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
-import org.opendaylight.yangtools.yang.model.ri.type.BitsTypeBuilder;
 
 /**
  * Unit tests for BitsCodecString.
  *
  * @author Thomas Pantelis
  */
-public class BitsCodecStringTest {
+class BitsCodecStringTest {
     private  static BitsTypeDefinition toBitsTypeDefinition(final String... bits) {
-        final BitsTypeBuilder b = BaseTypes.bitsTypeBuilder(QName.create("foo", "foo"));
+        final var b = BaseTypes.bitsTypeBuilder(QName.create("foo", "foo"));
 
         long pos = 0;
-        for (String bit : bits) {
-            BitsTypeDefinition.Bit mockBit = mock(BitsTypeDefinition.Bit.class);
+        for (var bit : bits) {
+            final var mockBit = mock(Bit.class);
             doReturn(bit).when(mockBit).getName();
             doReturn(Uint32.valueOf(pos)).when(mockBit).getPosition();
             b.addBit(mockBit);
@@ -46,26 +44,24 @@ public class BitsCodecStringTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        BitsCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(toBitsTypeDefinition("foo"),
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(toBitsTypeDefinition("foo"),
                 BitsCodec.class);
 
-        String serialized = codec.serialize(ImmutableSet.of("foo", "bar"));
-        assertNotNull(serialized);
-        assertTrue(serialized.contains("foo"));
-        assertTrue(serialized.contains("bar"));
+        final var serialized = ((BitsCodec<String>) codec).serialize(ImmutableSet.of("foo", "bar"));
+        assertEquals("foo bar", serialized);
 
-        assertEquals("", codec.serialize(ImmutableSet.of()));
+        assertEquals("", codec.serialize(Set.of()));
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        BitsCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(
+    void testDeserialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(
             toBitsTypeDefinition("bit1", "bit2"), BitsCodec.class);
 
-        assertEquals("deserialize", ImmutableSet.of("bit1", "bit2"), codec.deserialize("  bit1 bit2     "));
-        assertEquals("deserialize", Collections.emptySet(), codec.deserialize(""));
+        assertEquals(Set.of("bit1", "bit2"), codec.deserialize("  bit1 bit2     "), "deserialize");
+        assertEquals(Set.of(), codec.deserialize(""), "deserialize");
 
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "bit1 bit3");
     }
index 0223e9e624f05a3168cf2003dd8349f96cd964b1..8c29bd26709e64a7d7afb05f22348872a191b36d 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.BooleanCodec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
@@ -18,25 +18,25 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class BooleanCodecStringTest {
+class BooleanCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        BooleanCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.booleanType(),
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.booleanType(),
             BooleanCodec.class);
 
-        assertEquals("serialize", "true", codec.serialize(Boolean.TRUE));
-        assertEquals("serialize", "false", codec.serialize(Boolean.FALSE));
+        assertEquals("true", codec.serialize(Boolean.TRUE), "serialize");
+        assertEquals("false", codec.serialize(Boolean.FALSE), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        BooleanCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.booleanType(),
+    void testDeserialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.booleanType(),
             BooleanCodec.class);
 
-        assertEquals("deserialize", Boolean.TRUE, codec.deserialize("true"));
-        assertEquals("deserialize", Boolean.FALSE, codec.deserialize("false"));
+        assertEquals(Boolean.TRUE, codec.deserialize("true"), "deserialize");
+        assertEquals(Boolean.FALSE, codec.deserialize("false"), "deserialize");
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "TRUE");
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "FALSE");
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "foo");
index 8d564f0171dac689c1eda148978eb5df0982300f..cf557a39773834fc1c0b13f299240efe5ec431e1 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Decimal64;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.codec.DecimalCodec;
@@ -21,18 +21,18 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class DecimalCodecStringTest {
+class DecimalCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        DecimalCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(getType(), DecimalCodec.class);
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(getType(), DecimalCodec.class);
         assertEquals("123.456", codec.serialize(Decimal64.valueOf("123.456")));
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        DecimalCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(getType(), DecimalCodec.class);
+    void testDeserialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(getType(), DecimalCodec.class);
 
         assertEquals(Decimal64.valueOf("123.456"), codec.deserialize("123.456"));
 
index 8463474b665fb6eade6f318cc250b73d5ba167f1..16ec511f1d533a8fb42ccd35e5630cc0ef49683e 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.data.api.codec.EmptyCodec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
@@ -19,22 +19,21 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class EmptyCodecStringTest {
-
+class EmptyCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
 
-        assertEquals("serialize", "", codec.serialize(Empty.value()));
+        assertEquals("", codec.serialize(Empty.value()), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        EmptyCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
+    void testDeserialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.emptyType(), EmptyCodec.class);
 
-        assertEquals("deserialize", Empty.value(), codec.deserialize(""));
+        assertEquals(Empty.value(), codec.deserialize(""), "deserialize");
 
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "foo");
     }
index b9af6d6465f88edf38b2ee9ee8fb463160da8d26..d1574b16958bdee3e298f2de99799616b7b0a186 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.toEnumTypeDefinition;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.EnumCodec;
 
 /**
@@ -20,21 +20,21 @@ import org.opendaylight.yangtools.yang.data.api.codec.EnumCodec;
  *
  * @author Thomas Pantelis
  */
-public class EnumCodecStringTest {
+class EnumCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        EnumCodec<String> codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
-        assertEquals("serialize", "enum1", codec.serialize("enum1"));
+    void testSerialize() {
+        final var codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
+        assertEquals("enum1", codec.serialize("enum1"), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        EnumCodec<String> codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
+    void testDeserialize() {
+        final var codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
 
-        assertEquals("deserialize", "enum1", codec.deserialize("enum1"));
-        assertEquals("deserialize", "enum2", codec.deserialize("enum2"));
+        assertEquals("enum1", codec.deserialize("enum1"), "deserialize");
+        assertEquals("enum2", codec.deserialize("enum2"), "deserialize");
 
         deserializeWithExpectedIllegalArgEx(codec, "enum3");
     }
index 8771d9f418bd802fbb9d0bc9a4239153f31a2e25..b65f70bdca483f459c4599edd92784fdec8f3ac3 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int16Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
@@ -20,32 +20,32 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Int16CodecStringTest {
+class Int16CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Int16Codec<String> codec = getCodec(BaseTypes.int16Type(), Int16Codec.class);
-        assertEquals("serialize", "10", codec.serialize(Short.valueOf((short) 10)));
+    void testSerialize() {
+        final var codec = getCodec(BaseTypes.int16Type(), Int16Codec.class);
+        assertEquals("10", codec.serialize(Short.valueOf((short) 10)), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "+0X45c";
-        final String negHexa = "-0X45c";
-        final String octal = "02134";
-        final String negOctal = "-02134";
-        final String integer = "+1116";
-        final String negInteger = "-1116";
+    void testDeserialize() {
+        final var hexa = "+0X45c";
+        final var negHexa = "-0X45c";
+        final var octal = "02134";
+        final var negOctal = "-02134";
+        final var integer = "+1116";
+        final var negInteger = "-1116";
 
-        Int16Codec<String> codec = getCodec(BaseTypes.int16Type(), Int16Codec.class);
+        final var codec = getCodec(BaseTypes.int16Type(), Int16Codec.class);
 
-        assertEquals("deserialize", codec.deserialize(hexa), Short.valueOf("+045c", 16));
-        assertEquals("deserialize", codec.deserialize(negHexa), Short.valueOf("-045c", 16));
-        assertEquals("deserialize", codec.deserialize(octal), Short.valueOf(octal, 8));
-        assertEquals("deserialize", codec.deserialize(negOctal), Short.valueOf(negOctal, 8));
-        assertEquals("deserialize", codec.deserialize(integer), Short.valueOf(integer, 10));
-        assertEquals("deserialize", codec.deserialize(negInteger), Short.valueOf(negInteger, 10));
+        assertEquals(codec.deserialize(hexa), Short.valueOf("+045c", 16), "deserialize");
+        assertEquals(codec.deserialize(negHexa), Short.valueOf("-045c", 16), "deserialize");
+        assertEquals(codec.deserialize(octal), Short.valueOf(octal, 8), "deserialize");
+        assertEquals(codec.deserialize(negOctal), Short.valueOf(negOctal, 8), "deserialize");
+        assertEquals(codec.deserialize(integer), Short.valueOf(integer, 10), "deserialize");
+        assertEquals(codec.deserialize(negInteger), Short.valueOf(negInteger, 10), "deserialize");
 
         deserializeWithExpectedIllegalArgEx(codec, "1o");
         deserializeWithExpectedIllegalArgEx(codec, "");
index 248900e56cc5e056d771310f60650e8b25a96ec6..bef6a7a54b2b383f3a8241060c2420911d373dbe 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int32Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
@@ -18,32 +18,32 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Int32CodecStringTest {
+class Int32CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Int32Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int32Type(), Int32Codec.class);
-        assertEquals("serialize", "10", codec.serialize(Integer.valueOf(10)));
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int32Type(), Int32Codec.class);
+        assertEquals("10", codec.serialize(Integer.valueOf(10)), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "0x45FFFCDE";
-        final String negHexa = "-0x45FFFCDE";
-        final String octal = "010577776336";
-        final String negOctal = "-010577776336";
-        final String integer = "1174404318";
-        final String negInteger = "-1174404318";
+    void testDeserialize() {
+        final var hexa = "0x45FFFCDE";
+        final var negHexa = "-0x45FFFCDE";
+        final var octal = "010577776336";
+        final var negOctal = "-010577776336";
+        final var integer = "1174404318";
+        final var negInteger = "-1174404318";
 
-        Int32Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int32Type(), Int32Codec.class);
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int32Type(), Int32Codec.class);
 
-        assertEquals("deserialize", codec.deserialize(hexa), Integer.valueOf("+045FFFCDE", 16));
-        assertEquals("deserialize", codec.deserialize(negHexa), Integer.valueOf("-045FFFCDE", 16));
-        assertEquals("deserialize", codec.deserialize(octal), Integer.valueOf(octal, 8));
-        assertEquals("deserialize", codec.deserialize(negOctal), Integer.valueOf(negOctal, 8));
-        assertEquals("deserialize", codec.deserialize(integer), Integer.valueOf(integer, 10));
-        assertEquals("deserialize", codec.deserialize(negInteger), Integer.valueOf(negInteger, 10));
+        assertEquals(codec.deserialize(hexa), Integer.valueOf("+045FFFCDE", 16), "deserialize");
+        assertEquals(codec.deserialize(negHexa), Integer.valueOf("-045FFFCDE", 16), "deserialize");
+        assertEquals(codec.deserialize(octal), Integer.valueOf(octal, 8), "deserialize");
+        assertEquals(codec.deserialize(negOctal), Integer.valueOf(negOctal, 8), "deserialize");
+        assertEquals(codec.deserialize(integer), Integer.valueOf(integer, 10), "deserialize");
+        assertEquals(codec.deserialize(negInteger), Integer.valueOf(negInteger, 10), "deserialize");
 
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "1o");
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "");
index 784e4ba8efc6534f9a0a0c9c019d5274e12bc922..9ce04891c14470e372af340018c0ce004264efc4 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int64Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
@@ -20,33 +20,32 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Int64CodecStringTest {
-
+class Int64CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Int64Codec<String> codec = getCodec(BaseTypes.int64Type(), Int64Codec.class);
-        assertEquals("serialize", "12345", codec.serialize(Long.valueOf(12345)));
+    void testSerialize() {
+        final var codec = getCodec(BaseTypes.int64Type(), Int64Codec.class);
+        assertEquals("12345", codec.serialize(Long.valueOf(12345)), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "0X75EDC78edCBA";
-        final String negHexa = "-0X75EDC78edCBA";
-        final String octal = "+03536670743556272";
-        final String negOctal = "-03536670743556272";
-        final String integer = "+129664115727546";
-        final String negInteger = "-129664115727546";
-
-        Int64Codec<String> codec = getCodec(BaseTypes.int64Type(), Int64Codec.class);
-
-        assertEquals("deserialize", codec.deserialize(hexa), Long.valueOf("075EDC78edCBA", 16));
-        assertEquals("deserialize", codec.deserialize(negHexa), Long.valueOf("-075EDC78edCBA", 16));
-        assertEquals("deserialize", codec.deserialize(octal), Long.valueOf(octal, 8));
-        assertEquals("deserialize", codec.deserialize(negOctal), Long.valueOf(negOctal, 8));
-        assertEquals("deserialize", codec.deserialize(integer), Long.valueOf(integer, 10));
-        assertEquals("deserialize", codec.deserialize(negInteger), Long.valueOf(negInteger, 10));
+    void testDeserialize() {
+        final var hexa = "0X75EDC78edCBA";
+        final var negHexa = "-0X75EDC78edCBA";
+        final var octal = "+03536670743556272";
+        final var negOctal = "-03536670743556272";
+        final var integer = "+129664115727546";
+        final var negInteger = "-129664115727546";
+
+        final var codec = getCodec(BaseTypes.int64Type(), Int64Codec.class);
+
+        assertEquals(codec.deserialize(hexa), Long.valueOf("075EDC78edCBA", 16), "deserialize");
+        assertEquals(codec.deserialize(negHexa), Long.valueOf("-075EDC78edCBA", 16), "deserialize");
+        assertEquals(codec.deserialize(octal), Long.valueOf(octal, 8), "deserialize");
+        assertEquals(codec.deserialize(negOctal), Long.valueOf(negOctal, 8), "deserialize");
+        assertEquals(codec.deserialize(integer), Long.valueOf(integer, 10), "deserialize");
+        assertEquals(codec.deserialize(negInteger), Long.valueOf(negInteger, 10), "deserialize");
 
         deserializeWithExpectedIllegalArgEx(codec, "1234o");
         deserializeWithExpectedIllegalArgEx(codec, "");
index 325a776d5033b4e6af30730a3a376733980e4f70..518e5db2754c3c95111ad824701a811c2f80c6a6 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int8Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 
@@ -18,33 +18,33 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Int8CodecStringTest {
+class Int8CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Int8Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int8Type(), Int8Codec.class);
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int8Type(), Int8Codec.class);
 
-        assertEquals("serialize", "10", codec.serialize(Byte.valueOf((byte) 10)));
+        assertEquals("10", codec.serialize(Byte.valueOf((byte) 10)), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "0x40";
-        final String negHexa = "-0x40";
-        final String octal = "+0100";
-        final String negOctal = "-0100";
-        final String integer = "64";
-        final String negInteger = "-64";
-
-        Int8Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int8Type(), Int8Codec.class);
-
-        assertEquals("deserialize", codec.deserialize(hexa), Byte.valueOf("040", 16));
-        assertEquals("deserialize", codec.deserialize(negHexa), Byte.valueOf("-040", 16));
-        assertEquals("deserialize", codec.deserialize(octal), Byte.valueOf(octal, 8));
-        assertEquals("deserialize", codec.deserialize(negOctal), Byte.valueOf(negOctal, 8));
-        assertEquals("deserialize", codec.deserialize(integer), Byte.valueOf(integer, 10));
-        assertEquals("deserialize", codec.deserialize(negInteger), Byte.valueOf(negInteger, 10));
+    void testDeserialize() {
+        final var hexa = "0x40";
+        final var negHexa = "-0x40";
+        final var octal = "+0100";
+        final var negOctal = "-0100";
+        final var integer = "64";
+        final var negInteger = "-64";
+
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int8Type(), Int8Codec.class);
+
+        assertEquals(codec.deserialize(hexa), Byte.valueOf("040", 16), "deserialize");
+        assertEquals(codec.deserialize(negHexa), Byte.valueOf("-040", 16), "deserialize");
+        assertEquals(codec.deserialize(octal), Byte.valueOf(octal, 8), "deserialize");
+        assertEquals(codec.deserialize(negOctal), Byte.valueOf(negOctal, 8), "deserialize");
+        assertEquals(codec.deserialize(integer), Byte.valueOf(integer, 10), "deserialize");
+        assertEquals(codec.deserialize(negInteger), Byte.valueOf(negInteger, 10), "deserialize");
 
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "1o");
         TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx(codec, "");
index 87be6d8452a858523c059fb751a189a1bacbd084..b59f09701e69d1a175a8376005b3075a95702df2 100644 (file)
@@ -7,53 +7,51 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.codec.StringCodec;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.ValueRange;
-import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.ri.type.InvalidLengthConstraintException;
 import org.opendaylight.yangtools.yang.model.ri.type.RestrictedTypes;
-import org.opendaylight.yangtools.yang.model.ri.type.StringTypeBuilder;
 
 /**
  * Unit tests for StringCodecString.
  *
  * @author Thomas Pantelis
  */
-public class StringCodecStringTest {
+class StringCodecStringTest {
     @Test
-    public void testSerialize() {
-        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(),
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(),
             StringCodec.class);
 
-        assertEquals("serialize", "foo", codec.serialize("foo"));
-        assertEquals("serialize", "", codec.serialize(""));
+        assertEquals("foo", codec.serialize("foo"), "serialize");
+        assertEquals("", codec.serialize(""), "serialize");
     }
 
     @Test
-    public void testDeserialize() {
-        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(),
+    void testDeserialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(),
             StringCodec.class);
 
-        assertEquals("deserialize", "bar", codec.deserialize("bar"));
-        assertEquals("deserialize", "", codec.deserialize(""));
+        assertEquals("bar", codec.deserialize("bar"), "deserialize");
+        assertEquals("", codec.deserialize(""), "deserialize");
     }
 
     @Test
-    public void testDeserializeUnicode() throws InvalidLengthConstraintException {
-        final StringTypeBuilder builder = RestrictedTypes.newStringBuilder(BaseTypes.stringType(),
+    void testDeserializeUnicode() throws InvalidLengthConstraintException {
+        final var builder = RestrictedTypes.newStringBuilder(BaseTypes.stringType(),
             QName.create("foo", "foo"));
         builder.setLengthConstraint(mock(ConstraintMetaDefinition.class), List.of(ValueRange.of(1)));
-        final StringTypeDefinition type = builder.build();
+        final var type = builder.build();
 
-        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(type, StringCodec.class);
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(type, StringCodec.class);
 
         assertEquals("🌞", codec.deserialize("🌞"));
     }
index 88be76330bd611661d87e8525e1775a8432a112e..838da98feb4b47bcb82311a98806341e0cdb293f 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
@@ -21,9 +21,9 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class StringPatternCheckingCodecTest {
+class StringPatternCheckingCodecTest {
     @Test
-    public void testStringPatternCheckingCodec() {
+    void testStringPatternCheckingCodec() {
         final var schemaContext = YangParserTestUtils.parseYang("""
             module string-pattern-checking-codec-test {
               namespace "string-pattern-checking-codec-test";
index 77c9fbf80ba45c4e1753dac8768b6baa9d496999..fbbf00e9806827c93b57d843d31167361dd46056 100644 (file)
@@ -7,9 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
@@ -20,29 +19,28 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
-import org.opendaylight.yangtools.yang.model.ri.type.EnumerationTypeBuilder;
 
-public final class TypeDefinitionAwareCodecTestHelper {
+final class TypeDefinitionAwareCodecTestHelper {
     private TypeDefinitionAwareCodecTestHelper() {
         // Hidden on purpose
     }
 
-    public static <T> T getCodec(final TypeDefinition<?> def, final Class<T> clazz) {
-        TypeDefinitionAwareCodec<?, ?> codec = TypeDefinitionAwareCodec.fromType(def);
-        assertThat(codec, instanceOf(clazz));
+    static <T> T getCodec(final TypeDefinition<?> def, final Class<T> clazz) {
+        final var codec = TypeDefinitionAwareCodec.fromType(def);
+        assertInstanceOf(clazz, codec);
         return clazz.cast(codec);
     }
 
-    public static void deserializeWithExpectedIllegalArgEx(final IllegalArgumentCodec<String, ?> codec,
+    static void deserializeWithExpectedIllegalArgEx(final IllegalArgumentCodec<String, ?> codec,
             final @NonNull String param) {
         assertThrows(IllegalArgumentException.class, () -> codec.deserialize(param));
     }
 
-    public static EnumTypeDefinition toEnumTypeDefinition(final String... enums) {
-        final EnumerationTypeBuilder b = BaseTypes.enumerationTypeBuilder(QName.create("foo", "foo"));
-        int val = 0;
-        for (String en : enums) {
-            EnumTypeDefinition.EnumPair mockEnum = mock(EnumPair.class);
+    static EnumTypeDefinition toEnumTypeDefinition(final String... enums) {
+        final var b = BaseTypes.enumerationTypeBuilder(QName.create("foo", "foo"));
+        var val = 0;
+        for (final var en : enums) {
+            final var mockEnum = mock(EnumPair.class);
             doReturn(en).when(mockEnum).getName();
             doReturn(val).when(mockEnum).getValue();
             b.addEnum(mockEnum);
index b6776516093e4488f06888586dfe023c9cdd29b0..94988955177c07bb560794706602fbcacbf410e8 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint16Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
@@ -21,22 +21,22 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Uint16CodecStringTest {
+class Uint16CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Uint16Codec<String> codec = getCodec(BaseTypes.uint16Type(), Uint16Codec.class);
+    void testSerialize() {
+        final var codec = getCodec(BaseTypes.uint16Type(), Uint16Codec.class);
         assertEquals("10", codec.serialize(Uint16.valueOf(10)));
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "0X45c";
-        final String octal = "02134";
-        final String integer = "1116";
+    void testDeserialize() {
+        final var hexa = "0X45c";
+        final var octal = "02134";
+        final var integer = "1116";
 
-        Uint16Codec<String> codec = getCodec(BaseTypes.uint16Type(), Uint16Codec.class);
+        final var codec = getCodec(BaseTypes.uint16Type(), Uint16Codec.class);
 
         assertEquals(Uint16.valueOf("045c", 16), codec.deserialize(hexa));
         assertEquals(Uint16.valueOf(octal, 8), codec.deserialize(octal));
index 24640fac03e9baf7e78bca89c8b42c25afa660dc..cfe3afbf4b38225684e25914d9e1251728658eaa 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint32Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
@@ -21,22 +21,22 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Uint32CodecStringTest {
+class Uint32CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Uint32Codec<String> codec = getCodec(BaseTypes.uint32Type(), Uint32Codec.class);
+    void testSerialize() {
+        final var codec = getCodec(BaseTypes.uint32Type(), Uint32Codec.class);
         assertEquals("10", codec.serialize(Uint32.valueOf(10)));
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "0x45FFFCDE";
-        final String octal = "010577776336";
-        final String integer = "1174404318";
+    void testDeserialize() {
+        final var hexa = "0x45FFFCDE";
+        final var octal = "010577776336";
+        final var integer = "1174404318";
 
-        Uint32Codec<String> codec = getCodec(BaseTypes.uint32Type(), Uint32Codec.class);
+        final var codec = getCodec(BaseTypes.uint32Type(), Uint32Codec.class);
         assertEquals(Uint32.valueOf("45FFFCDE", 16), codec.deserialize(hexa));
         assertEquals(Uint32.valueOf(octal, 8), codec.deserialize(octal));
         assertEquals(Uint32.valueOf(integer, 10), codec.deserialize(integer));
index 33318b56adb787577d742d2c822383267c5c5105..020327354ddb862b45476b435808522eb282c2d4 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Uint64;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint64Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
@@ -19,23 +19,23 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Uint64CodecStringTest {
+class Uint64CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
+    void testSerialize() {
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
             Uint64Codec.class);
         assertEquals("123456789", codec.serialize(Uint64.valueOf(123456789)));
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        final String hexa = "0X75EDC78edCBA";
-        final String octal = "03536670743556272";
-        final String integer = "129664115727546";
+    void testDeserialize() {
+        final var hexa = "0X75EDC78edCBA";
+        final var octal = "03536670743556272";
+        final var integer = "129664115727546";
 
-        Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
+        final var codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
             Uint64Codec.class);
 
         assertEquals(Uint64.valueOf("75EDC78edCBA", 16), codec.deserialize(hexa));
index 526c86c0d52d13b338a1c9ab0ac7957282568243..efd86dc12e5f9e2aec69aa6b2973875f8d1f176f 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Uint8;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint8Codec;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
@@ -21,22 +21,22 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
  *
  * @author Thomas Pantelis
  */
-public class Uint8CodecStringTest {
-    @SuppressWarnings({ "unchecked" })
+class Uint8CodecStringTest {
+    @SuppressWarnings({"unchecked"})
     @Test
-    public void testSerialize() {
-        Uint8Codec<String> codec = getCodec(BaseTypes.uint8Type(), Uint8Codec.class);
+    void testSerialize() {
+        final var codec = getCodec(BaseTypes.uint8Type(), Uint8Codec.class);
         assertEquals("10", codec.serialize(Uint8.valueOf((short) 10)));
     }
 
-    @SuppressWarnings({ "unchecked" })
+    @SuppressWarnings({"unchecked"})
     @Test
-    public void testDererialize() {
-        final String hexa = "0x40";
-        final String octal = "0100";
-        final String integer = "64";
+    void testDererialize() {
+        final var hexa = "0x40";
+        final var octal = "0100";
+        final var integer = "64";
 
-        Uint8Codec<String> codec = getCodec(BaseTypes.uint8Type(), Uint8Codec.class);
+        final var codec = getCodec(BaseTypes.uint8Type(), Uint8Codec.class);
 
         assertEquals(Uint8.valueOf("040", 16), codec.deserialize(hexa));
         assertEquals(Uint8.valueOf(octal, 8), codec.deserialize(octal));
index bb02423d26b7adeff26a694c8b51741e8831a4e9..49640f9e736be080ca5cc9e8f29c189bf3ccfd83 100644 (file)
@@ -7,30 +7,29 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.toEnumTypeDefinition;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.codec.UnionCodec;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
-import org.opendaylight.yangtools.yang.model.ri.type.UnionTypeBuilder;
 
 /**
  * Unit tests forUnionCodecString.
  *
  * @author Thomas Pantelis
  */
-public class UnionCodecStringTest {
+class UnionCodecStringTest {
     private static UnionTypeDefinition toUnionTypeDefinition(final TypeDefinition<?>... types) {
-        final UnionTypeBuilder builder = BaseTypes.unionTypeBuilder(QName.create("foo", "foo"));
+        final var builder = BaseTypes.unionTypeBuilder(QName.create("foo", "foo"));
 
-        for (TypeDefinition<?> t : types) {
+        for (final var t : types) {
             builder.addType(t);
         }
 
@@ -39,29 +38,29 @@ public class UnionCodecStringTest {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testSerialize() {
-        UnionCodec<String> codec = getCodec(toUnionTypeDefinition(toEnumTypeDefinition("enum1", "enum2"),
+    void testSerialize() {
+        final var codec = getCodec(toUnionTypeDefinition(toEnumTypeDefinition("enum1", "enum2"),
                 toUnionTypeDefinition(BaseTypes.int32Type(),BaseTypes.int64Type()), BaseTypes.emptyType()),
                 UnionCodec.class);
 
-        assertEquals("serialize", "enum1", codec.serialize("enum1"));
-        assertEquals("serialize", "123", codec.serialize("123"));
-        assertEquals("serialize", "123", codec.serialize(123));
-        assertEquals("serialize", "", codec.serialize(""));
+        assertEquals("enum1", codec.serialize("enum1"), "serialize");
+        assertEquals("123", codec.serialize("123"), "serialize");
+        assertEquals("123", codec.serialize(123), "serialize");
+        assertEquals("", codec.serialize(""), "serialize");
     }
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testDeserialize() {
-        UnionCodec<String> codec = getCodec(toUnionTypeDefinition(toEnumTypeDefinition("enum1", "enum2"),
+    void testDeserialize() {
+        final var codec = getCodec(toUnionTypeDefinition(toEnumTypeDefinition("enum1", "enum2"),
                 toUnionTypeDefinition(BaseTypes.int32Type(),BaseTypes.int64Type()), BaseTypes.emptyType()),
                 UnionCodec.class);
 
-        assertEquals("deserialize", "enum1", codec.deserialize("enum1"));
-        assertEquals("deserialize", 123, codec.deserialize("123"));
-        assertEquals("deserialize", -123, codec.deserialize("-123"));
-        assertEquals("deserialize", 41234567890L, codec.deserialize("41234567890"));
-        assertEquals("deserialize", Empty.value(), codec.deserialize(""));
+        assertEquals("enum1", codec.deserialize("enum1"), "deserialize");
+        assertEquals(123, codec.deserialize("123"), "deserialize");
+        assertEquals(-123, codec.deserialize("-123"), "deserialize");
+        assertEquals(41234567890L, codec.deserialize("41234567890"), "deserialize");
+        assertEquals(Empty.value(), codec.deserialize(""), "deserialize");
 
         deserializeWithExpectedIllegalArgEx(codec, "enum3");
         deserializeWithExpectedIllegalArgEx(codec, "123o");
index 60220246a25412d2602277a23f3869ff39951459..e97f972ac4e3451b91a609cf6a281ecb5592be91 100644 (file)
@@ -7,21 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class YT1097Test {
+class YT1097Test {
     @Test
-    public void testBooleanStringUnion() {
-        final Module module = YangParserTestUtils.parseYang("""
+    void testBooleanStringUnion() {
+        final var module = YangParserTestUtils.parseYang("""
             module yt1097 {
               namespace yt1097;
               prefix yt1097;
@@ -33,12 +30,11 @@ public class YT1097Test {
                 }
               }
             }""").findModule("yt1097").orElseThrow();
-        final DataSchemaNode foo = module.findDataChildByName(QName.create(module.getQNameModule(), "foo"))
-                .orElseThrow();
-        assertThat(foo, instanceOf(LeafSchemaNode.class));
+        final var foo = module.findDataChildByName(QName.create(module.getQNameModule(), "foo")).orElseThrow();
+        assertInstanceOf(LeafSchemaNode.class, foo);
 
-        final TypeDefinitionAwareCodec<?, ?> codec = TypeDefinitionAwareCodec.from(((LeafSchemaNode) foo).getType());
-        assertThat(codec, instanceOf(UnionStringCodec.class));
+        final var codec = TypeDefinitionAwareCodec.from(((LeafSchemaNode) foo).getType());
+        assertInstanceOf(UnionStringCodec.class, codec);
 
         assertDecoded(codec, Boolean.TRUE, "true");
         assertDecoded(codec, Boolean.FALSE, "false");
@@ -54,8 +50,6 @@ public class YT1097Test {
 
     private static void assertDecoded(final TypeDefinitionAwareCodec<?, ?> codec, final Object expected,
             final String input) {
-        final Object result = codec.deserialize(input);
-        assertThat(result, instanceOf(expected.getClass()));
-        assertEquals(expected, result);
+        assertEquals(expected, assertInstanceOf(expected.getClass(), codec.deserialize(input)));
     }
 }
index 1559a8a2b4a48b193efb47f290f12d044dfdc4fb..25be626654da7927ae57d43ccbf0a3fdf580894c 100644 (file)
@@ -7,18 +7,17 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class YT1437Test {
+class YT1437Test {
     @Test
-    public void testDecimalFractionDigits() {
+    void testDecimalFractionDigits() {
         final var module = YangParserTestUtils.parseYang("""
             module yt1437 {
               namespace yt1437;
@@ -32,22 +31,20 @@ public class YT1437Test {
               }
             }""").findModule("yt1437").orElseThrow();
         final var foo = module.findDataChildByName(QName.create(module.getQNameModule(), "foo")).orElseThrow();
-        assertThat(foo, instanceOf(LeafSchemaNode.class));
 
-        final TypeDefinitionAwareCodec<?, ?> codec = TypeDefinitionAwareCodec.from(((LeafSchemaNode) foo).getType());
-        assertThat(codec, instanceOf(DecimalStringCodec.class));
-        final var cast = (DecimalStringCodec) codec;
+        final var codec = assertInstanceOf(DecimalStringCodec.class,
+            TypeDefinitionAwareCodec.from(assertInstanceOf(LeafSchemaNode.class, foo).getType()));
 
-        final var one = cast.deserialize("20.0");
+        final var one = codec.deserialize("20.0");
         assertEquals(2, one.scale());
-        assertEquals("20.0", cast.serialize(one));
+        assertEquals("20.0", codec.serialize(one));
 
-        final var two = cast.deserialize("20.00");
+        final var two = codec.deserialize("20.00");
         assertEquals(2, two.scale());
-        assertEquals("20.0", cast.serialize(two));
+        assertEquals("20.0", codec.serialize(two));
 
-        final var three = cast.deserialize("20.000");
+        final var three = codec.deserialize("20.000");
         assertEquals(2, three.scale());
-        assertEquals("20.0", cast.serialize(three));
+        assertEquals("20.0", codec.serialize(three));
     }
 }
index bee70b55a0ca5ae5b32611f38bab55f3eb13118e..711f24e308e80236184bb68dac0d333111d8e101 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.codec;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.Decimal64;
 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
@@ -25,11 +24,11 @@ import org.opendaylight.yangtools.yang.data.api.codec.YangInvalidValueException;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class YT1442Test {
+class YT1442Test {
     private static DecimalStringCodec codec;
 
-    @BeforeClass
-    public static void beforeClass() {
+    @BeforeAll
+    static void beforeClass() {
         final var foo = YangParserTestUtils.parseYang("""
             module yt1442 {
               namespace yt1442;
@@ -46,68 +45,62 @@ public class YT1442Test {
               }
             }""")
             .getDataChildByName(QName.create("yt1442", "foo"));
-        assertThat(foo, instanceOf(LeafSchemaNode.class));
-
-        final TypeDefinitionAwareCodec<?, ?> tmp = TypeDefinitionAwareCodec.from(((LeafSchemaNode) foo).getType());
-        assertThat(tmp, instanceOf(DecimalStringCodec.class));
-        codec = (DecimalStringCodec) tmp;
+        codec = assertInstanceOf(DecimalStringCodec.class,
+            TypeDefinitionAwareCodec.from(assertInstanceOf(LeafSchemaNode.class, foo).getType()));
     }
 
     @Test
-    public void testTen() {
+    void testTen() {
         final var ten = codec.deserialize("10.00");
         assertDecimal(1000, ten);
         assertEquals("10.0", codec.serialize(ten));
     }
 
     @Test
-    public void testFifty() {
+    void testFifty() {
         final var fifty = codec.deserialize("50.00");
         assertDecimal(5000, fifty);
         assertEquals("50.0", codec.serialize(fifty));
     }
 
     @Test
-    public void testHundred() {
+    void testHundred() {
         final var hundred = codec.deserialize("100.00");
         assertDecimal(10000, hundred);
         assertEquals("100.0", codec.serialize(hundred));
     }
 
     @Test
-    public void testNegativeOutOfRange() {
+    void testNegativeOutOfRange() {
         assertYIVE("Value '-10.0' is not in required ranges [[10.0..100.0]]", "-10.00");
         assertYIVE("Value '-50.0' is not in required ranges [[10.0..100.0]]", "-50.00");
         assertYIVE("Value '-100.0' is not in required ranges [[10.0..100.0]]", "-100.00");
     }
 
     @Test
-    public void testPositiveOutOfRange() {
+    void testPositiveOutOfRange() {
         assertYIVE("Value '9.99' is not in required ranges [[10.0..100.0]]", "9.99");
         assertYIVE("Value '100.01' is not in required ranges [[10.0..100.0]]", "100.01");
     }
 
     @Test
-    public void testTooLargeFractionPart() {
+    void testTooLargeFractionPart() {
         final var ex = assertThrows(IllegalArgumentException.class, () -> codec.deserialize("100.001"));
         assertEquals("Value '100.001' does not match required fraction-digits", ex.getMessage());
-        final var cause = ex.getCause();
-        assertThat(cause, instanceOf(ArithmeticException.class));
+        final var cause = assertInstanceOf(ArithmeticException.class, ex.getCause());
         assertEquals("Decreasing scale of 100.001 to 2 requires rounding", cause.getMessage());
     }
 
     @Test
-    public void testTooLargeIntegralPart() {
+    void testTooLargeIntegralPart() {
         final var ex = assertThrows(IllegalArgumentException.class, () -> codec.deserialize("92233720368547759.0"));
         assertEquals("Value '92233720368547759.0' does not match required fraction-digits", ex.getMessage());
-        final var cause = ex.getCause();
-        assertThat(cause, instanceOf(ArithmeticException.class));
+        final var cause = assertInstanceOf(ArithmeticException.class, ex.getCause());
         assertEquals("Increasing scale of 92233720368547759.0 to 2 would overflow", cause.getMessage());
     }
 
     private static void assertDecimal(final long unscaledValue, final Object obj) {
-        assertThat(obj, instanceOf(Decimal64.class));
-        final var actual = (Decimal64) obj;
+        final var actual = assertInstanceOf(Decimal64.class, obj);
         assertEquals(2, actual.scale());
         assertEquals(unscaledValue, actual.unscaledValue());
     }
index bab06ecc21071bc65543449099f8dd605b3000e2..b9e60a3e23e3d521aed818883611dd20c5ed4fb6 100644 (file)
@@ -8,34 +8,20 @@
 
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.yangtools.util.UnmodifiableCollection;
+import java.util.List;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.SystemLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
@@ -46,14 +32,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUn
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserMapNodeBuilder;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class BuilderTest {
+class BuilderTest {
     private static final QName ROOT_CONTAINER = QName.create("test.namespace.builder.test", "2016-01-01",
         "root-container");
     private static final QName LIST_MAIN = QName.create(ROOT_CONTAINER, "list-ordered-by-user-with-key");
@@ -71,69 +51,28 @@ public class BuilderTest {
     private static final int SIZE = 3;
     private static final NodeWithValue<String> BAR_PATH = new NodeWithValue<>(LEAF_LIST_MAIN, "bar");
     private static final LeafSetEntryNode<String> LEAF_SET_ENTRY_NODE =
-            ImmutableLeafSetEntryNodeBuilder.<String>create()
-            .withNodeIdentifier(BAR_PATH)
-            .withValue("bar")
-            .build();
-    private ListSchemaNode list;
-    private LeafListSchemaNode leafList;
-
-    @Before
-    public void setup() throws URISyntaxException {
-        final var schema = YangParserTestUtils.parseYang("""
-            module immutable-ordered-map-node {
-              yang-version 1;
-              namespace "test.namespace.builder.test";
-              prefix "iomn";
-
-              revision "2016-01-01" {
-                description "Initial revision.";
-              }
-
-              container root-container {
-                list list-ordered-by-user-with-key {
-                  key "leaf-a";
-                  ordered-by "user";
-                  leaf leaf-a {
-                    type string;
-                  }
-                }
-                leaf-list leaf-list-ordered-by-user {
-                  ordered-by "user";
-                  type string;
-                }
-              }
-            }""");
-        final Module module = schema.getModules().iterator().next();
-        final DataSchemaNode root = module.getDataChildByName(ROOT_CONTAINER);
-        list = (ListSchemaNode)((ContainerSchemaNode) root).getDataChildByName(LIST_MAIN);
-        leafList = (LeafListSchemaNode)((ContainerSchemaNode) root).getDataChildByName(LEAF_LIST_MAIN);
-    }
+            ImmutableLeafSetEntryNodeBuilder.<String>create().withNodeIdentifier(BAR_PATH).withValue("bar").build();
 
     @Test
-    public void immutableOrderedMapBuilderTest() {
-        final var mapEntryNodeColl = new LinkedList<MapEntryNode>();
-        mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
-        final var keys = new HashMap<QName, Object>();
-        keys.put(LIST_MAIN_CHILD_QNAME_1, 1);
-        final NodeIdentifierWithPredicates mapEntryPath = NodeIdentifierWithPredicates.of(LIST_MAIN, keys);
-        final UserMapNode orderedMapNodeCreateNull = ImmutableUserMapNodeBuilder.create()
+    void immutableOrderedMapBuilderTest() {
+        final var mapEntryPath = NodeIdentifierWithPredicates.of(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 1);
+        final var orderedMapNodeCreateNull = ImmutableUserMapNodeBuilder.create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .withChild(LIST_MAIN_CHILD_1)
                 .addChild(LIST_MAIN_CHILD_2)
-                .withValue(mapEntryNodeColl)
+                .withValue(List.of(LIST_MAIN_CHILD_3))
                 .build();
-        final UserMapNode orderedMapNodeCreateSize = ImmutableUserMapNodeBuilder.create(SIZE)
+        final var orderedMapNodeCreateSize = ImmutableUserMapNodeBuilder.create(SIZE)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
-        final UserMapNode orderedMapNodeCreateNode = ImmutableUserMapNodeBuilder.create(orderedMapNodeCreateNull)
+        final var orderedMapNodeCreateNode = ImmutableUserMapNodeBuilder.create(orderedMapNodeCreateNull)
                 .removeChild(mapEntryPath)
                 .build();
-        final UserMapNode orderedMapNodeSchemaAware = ImmutableUserMapNodeBuilder.create()
+        final var orderedMapNodeSchemaAware = ImmutableUserMapNodeBuilder.create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .withChild(LIST_MAIN_CHILD_1)
                 .build();
-        final UserMapNode orderedMapNodeSchemaAwareMapNodeConst =
+        final var orderedMapNodeSchemaAwareMapNodeConst =
                 ImmutableUserMapNodeBuilder.create(getImmutableUserMapNode())
                 .build();
 
@@ -146,73 +85,64 @@ public class BuilderTest {
     }
 
     @Test
-    public void immutableUserLeafSetNodeBuilderTest() {
-        final UserLeafSetNode<String> orderedLeafSet = ImmutableUserLeafSetNodeBuilder.<String>create()
+    void immutableUserLeafSetNodeBuilderTest() {
+        final var orderedLeafSet = ImmutableUserLeafSetNodeBuilder.<String>create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .withChild(LEAF_SET_ENTRY_NODE)
                 .withChildValue("baz")
                 .removeChild(BAR_PATH)
                 .build();
-        final LinkedList<LeafSetNode<?>> mapEntryNodeColl = new LinkedList<>();
-        mapEntryNodeColl.add(orderedLeafSet);
-        final UnmodifiableCollection<?> leafSetCollection = (UnmodifiableCollection<?>)orderedLeafSet.body();
-        final NormalizedNode orderedMapNodeSchemaAware = ImmutableUserLeafSetNodeBuilder.create()
+        final var orderedMapNodeSchemaAware = ImmutableUserLeafSetNodeBuilder.create()
             .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
             .withChildValue("baz")
             .build();
-        final UnmodifiableCollection<?> SchemaAwareleafSetCollection =
-                (UnmodifiableCollection<?>) orderedMapNodeSchemaAware.body();
 
         assertNotNull(Builders.anyXmlBuilder());
-        assertEquals(1, ((UserLeafSetNode<?>)orderedLeafSet).size());
+        assertEquals(1, orderedLeafSet.size());
         assertEquals("baz", orderedLeafSet.childAt(0).body());
         assertNull(orderedLeafSet.childByArg(BAR_PATH));
-        assertEquals(1, leafSetCollection.size());
-        assertEquals(1, SchemaAwareleafSetCollection.size());
+        assertEquals(1, orderedLeafSet.size());
+        assertEquals(1, orderedMapNodeSchemaAware.size());
     }
 
     @Test
-    public void immutableMapNodeBuilderTest() {
-        final LinkedList<MapEntryNode> mapEntryNodeColl = new LinkedList<>();
-        mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
-        final CollectionNodeBuilder<MapEntryNode, SystemMapNode> collectionNodeBuilder =
-            ImmutableMapNodeBuilder.create(1);
-        assertNotNull(collectionNodeBuilder);
-        collectionNodeBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST);
-        collectionNodeBuilder.withValue(mapEntryNodeColl);
-        final SystemMapNode mapNode = collectionNodeBuilder.build();
+    void immutableMapNodeBuilderTest() {
+        final var mapNode = ImmutableMapNodeBuilder.create(1)
+            .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
+            .withValue(List.of(LIST_MAIN_CHILD_3))
+            .build();
         assertNotNull(Builders.mapBuilder(mapNode));
     }
 
     @Test
-    public void immutableUnkeyedListEntryNodeBuilderTest() {
-        final UnkeyedListEntryNode unkeyedListEntryNode = ImmutableUnkeyedListEntryNodeBuilder.create()
+    void immutableUnkeyedListEntryNodeBuilderTest() {
+        final var unkeyedListEntryNode = ImmutableUnkeyedListEntryNodeBuilder.create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
-        final UnkeyedListEntryNode unkeyedListEntryNodeSize = ImmutableUnkeyedListEntryNodeBuilder.create(1)
+        final var unkeyedListEntryNodeSize = ImmutableUnkeyedListEntryNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
-        final UnkeyedListEntryNode unkeyedListEntryNodeNode = ImmutableUnkeyedListEntryNodeBuilder
+        final var unkeyedListEntryNodeNode = ImmutableUnkeyedListEntryNodeBuilder
                 .create(unkeyedListEntryNode).build();
         assertEquals(unkeyedListEntryNode.name(), unkeyedListEntryNodeSize.name());
         assertEquals(unkeyedListEntryNodeSize.name(), unkeyedListEntryNodeNode.name());
     }
 
     @Test
-    public void immutableUnkeyedListNodeBuilderTest() {
-        final UnkeyedListEntryNode unkeyedListEntryNode = ImmutableUnkeyedListEntryNodeBuilder.create()
+    void immutableUnkeyedListNodeBuilderTest() {
+        final var unkeyedListEntryNode = ImmutableUnkeyedListEntryNodeBuilder.create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF)
                 .build();
-        final ImmutableUnkeyedListNodeBuilder immutableUnkeyedListNodeBuilder = (ImmutableUnkeyedListNodeBuilder)
+        final var immutableUnkeyedListNodeBuilder = (ImmutableUnkeyedListNodeBuilder)
                 ImmutableUnkeyedListNodeBuilder.create();
-        final UnkeyedListNode unkeyedListNode = immutableUnkeyedListNodeBuilder
+        final var unkeyedListNode = immutableUnkeyedListNodeBuilder
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .addChild(unkeyedListEntryNode)
                 .build();
-        final UnkeyedListNode unkeyedListNodeSize = ImmutableUnkeyedListNodeBuilder.create(1)
+        final var unkeyedListNodeSize = ImmutableUnkeyedListNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .build();
-        final UnkeyedListNode unkeyedListNodeCreated = ImmutableUnkeyedListNodeBuilder.create(unkeyedListNode)
+        final var unkeyedListNodeCreated = ImmutableUnkeyedListNodeBuilder.create(unkeyedListNode)
                 .build();
 
         assertThrows(IndexOutOfBoundsException.class, () -> unkeyedListNodeSize.childAt(1));
@@ -224,48 +154,41 @@ public class BuilderTest {
     }
 
     @Test
-    public void immutableChoiceNodeBuilderTest() {
-        final ChoiceNode choiceNode = ImmutableChoiceNodeBuilder.create(1).withNodeIdentifier(NODE_IDENTIFIER_LIST)
+    void immutableChoiceNodeBuilderTest() {
+        final var choiceNode = ImmutableChoiceNodeBuilder.create(1).withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
-        final ChoiceNode choiceNodeCreated = ImmutableChoiceNodeBuilder.create(choiceNode).build();
+        final var choiceNodeCreated = ImmutableChoiceNodeBuilder.create(choiceNode).build();
         assertEquals(choiceNodeCreated.name(), choiceNode.name());
     }
 
     @Test
-    public void immutableContainerNodeBuilderExceptionTest() {
-        final ContainerNode immutableContainerNode = ImmutableContainerNodeBuilder.create(1)
+    void immutableContainerNodeBuilderExceptionTest() {
+        final var immutableContainerNode = ImmutableContainerNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
         assertNotNull(immutableContainerNode);
     }
 
     @Test
-    public void immutableLeafSetNodeBuilderExceptionTest() {
-        final SystemLeafSetNode<Object> leafSetNode = ImmutableLeafSetNodeBuilder.create(1)
+    void immutableLeafSetNodeBuilderExceptionTest() {
+        final var leafSetNode = ImmutableLeafSetNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .build();
         assertNotNull(leafSetNode);
     }
 
     @Test
-    public void immutableMapEntryNodeBuilderExceptionTest() {
+    void immutableMapEntryNodeBuilderExceptionTest() {
         final var builder = ImmutableMapEntryNodeBuilder.create(1);
         assertThrows(NullPointerException.class, builder::build);
     }
 
     @Test
-    public void immutableUnkeyedListNodeBuilderExceptionTest() {
+    void immutableUnkeyedListNodeBuilderExceptionTest() {
         final var builder = ImmutableUnkeyedListNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LEAF);
         assertThrows(UnsupportedOperationException.class, () -> builder.removeChild(NODE_IDENTIFIER_LIST));
     }
 
-    private static SystemMapNode getImmutableMapNode() {
-        return ImmutableMapNodeBuilder.create()
-            .withNodeIdentifier(NODE_IDENTIFIER_LIST)
-            .withChild(LIST_MAIN_CHILD_1)
-            .build();
-    }
-
     private static UserMapNode getImmutableUserMapNode() {
         return ImmutableUserMapNodeBuilder.create()
             .withNodeIdentifier(NODE_IDENTIFIER_LIST)
index 9d48b9fca49fb082e26735c0ffb7da5de0f2f984..be8a3d2e9cba39c84bcacfbaf482d440907d85a9 100644 (file)
@@ -7,16 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.io.IOException;
-import java.text.ParseException;
 import java.util.List;
 import java.util.Map;
 import javax.xml.transform.dom.DOMSource;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
@@ -27,7 +25,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithV
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
 
-public class ImmutableNormalizedNodeStreamWriterTest {
+class ImmutableNormalizedNodeStreamWriterTest {
 
     private QNameModule bazModule;
 
@@ -64,8 +62,8 @@ public class ImmutableNormalizedNodeStreamWriterTest {
 
     private DOMSource anyxmlDomSource;
 
-    @Before
-    public void setup() throws ParseException {
+    @Test
+    void testImmutableNormalizedNodeStreamWriter() throws IOException {
         bazModule = QNameModule.create(XMLNamespace.of("baz-namespace"), Revision.of("1970-01-01"));
 
         outerContainer = QName.create(bazModule, "outer-container");
@@ -100,10 +98,7 @@ public class ImmutableNormalizedNodeStreamWriterTest {
         myLeafInList3 = QName.create(bazModule, "my-leaf-in-list-3");
 
         anyxmlDomSource = new DOMSource();
-    }
 
-    @Test
-    public void testImmutableNormalizedNodeStreamWriter() throws IOException {
         final var result = new NormalizationResultHolder();
         final var immutableNormalizedNodeStreamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
         final var normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(immutableNormalizedNodeStreamWriter);
index 3827b5a413416786aec90fa40a1ac8b00e0c18ee..9a89ef3b9297b8ccd140f07e59070e9f73adb448 100644 (file)
@@ -7,31 +7,27 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 import com.google.common.collect.ImmutableMap;
-import java.util.Collection;
 import java.util.Map;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class InstanceIdToNodesTest {
+class InstanceIdToNodesTest {
 
     private static final String NS = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:normalization:test";
     private static final String REVISION = "2014-03-13";
@@ -50,18 +46,18 @@ public class InstanceIdToNodesTest {
     private final NodeIdentifier leafList = new NodeIdentifier(QName.create(NS, REVISION, "ordered-leaf-list"));
     private final NodeWithValue<?> leafListWithValue = new NodeWithValue<>(leafList.getNodeType(), "abcd");
 
-    @BeforeClass
-    public static void setUp() {
+    @BeforeAll
+    static void setUp() {
         ctx = YangParserTestUtils.parseYangResources(InstanceIdToNodesTest.class, "/filter-test.yang");
     }
 
-    @AfterClass
-    public static void teardown() {
+    @AfterAll
+    static void teardown() {
         ctx = null;
     }
 
     @Test
-    public void testListLastChildOverride() {
+    void testListLastChildOverride() {
         assertEquals(Builders.containerBuilder()
             .withNodeIdentifier(rootContainer)
             .withChild(Builders.mapBuilder()
@@ -79,7 +75,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testLeafList() {
+    void testLeafList() {
         assertEquals(Builders.containerBuilder()
             .withNodeIdentifier(rootContainer)
             .withChild(Builders.orderedLeafSetBuilder()
@@ -94,22 +90,21 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testEmptyInstanceIdentifier() {
+    void testEmptyInstanceIdentifier() {
         assertEquals(ImmutableNodes.containerNode(SchemaContext.NAME),
             ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of()));
     }
 
     @Test
-    public void testKeyOrdering() {
+    void testKeyOrdering() {
         final Map<QName, Object> misordered = ImmutableOffsetMap.orderedCopyOf(ImmutableMap.of(BAR, "bar", FOO, "foo"));
-        final NodeIdentifierWithPredicates id = NodeIdentifierWithPredicates.of(TWO_KEY_LIST.getNodeType(), misordered);
+        final var id = NodeIdentifierWithPredicates.of(TWO_KEY_LIST.getNodeType(), misordered);
         assertArrayEquals(new Object[] { BAR, FOO }, id.keySet().toArray());
 
-        final NormalizedNode filter = ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(TWO_KEY_LIST, id));
-        assertThat(filter, isA(MapNode.class));
-        final Collection<MapEntryNode> value = ((MapNode) filter).body();
+        final var filter = ImmutableNodes.fromInstanceId(ctx, YangInstanceIdentifier.of(TWO_KEY_LIST, id));
+        final var value = assertInstanceOf(MapNode.class, filter).body();
         assertEquals(1, value.size());
-        final MapEntryNode entry = value.iterator().next();
+        final var entry = value.iterator().next();
 
         // The entry must have a the proper order
         assertArrayEquals(new Object[] { FOO, BAR }, entry.name().keySet().toArray());
index c77fc1c0493267fa69527c663357a899f0cf8ec0..686d46effcbe041cd4eca93dad81fd1b3edfa8e4 100644 (file)
@@ -7,64 +7,55 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
 
-public class NormalizedDataBuilderTest {
+class NormalizedDataBuilderTest {
     @Test
-    public void testSchemaUnaware() {
+    void testSchemaUnaware() {
         // Container
-        DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = Builders
-                .containerBuilder().withNodeIdentifier(getNodeIdentifier("container"));
-
-        // leaf
-        LeafNode<String> leafChild = Builders.<String>leafBuilder().withNodeIdentifier(getNodeIdentifier("leaf"))
-                .withValue("String").build();
-        builder.withChild(leafChild);
-
-        // leafList
-        LeafSetNode<Integer> leafList = Builders.<Integer>leafSetBuilder()
+        final var builder = Builders.containerBuilder()
+            .withNodeIdentifier(getNodeIdentifier("container"))
+            .withChild(Builders.<String>leafBuilder()
+                .withNodeIdentifier(getNodeIdentifier("leaf"))
+                .withValue("String")
+                .build())
+            .withChild(Builders.<Integer>leafSetBuilder()
                 .withNodeIdentifier(getNodeIdentifier("leaf"))
                 .withChildValue(1)
                 .withChild(Builders.<Integer>leafSetEntryBuilder()
-                        .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3)).withValue(3).build())
-                .build();
-        builder.withChild(leafList);
-
-        // list
-        MapEntryNode listChild1 = Builders
-                .mapEntryBuilder()
-                .withChild(
-                        Builders.<Integer>leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList"))
-                                .withValue(1).build())
-                .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build())
-                .withNodeIdentifier(NodeIdentifierWithPredicates.of(
-                                getNodeIdentifier("list").getNodeType(), Collections.singletonMap(
-                                getNodeIdentifier("uint32InList").getNodeType(), 1))).build();
-
-        builder
+                    .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3))
+                    .withValue(3)
+                    .build())
+                .build())
             .withChild(Builders.mapBuilder()
                 .withNodeIdentifier(getNodeIdentifier("list"))
-                .withChild(listChild1)
+                .withChild(Builders.mapEntryBuilder()
+                    .withChild(Builders.<Integer>leafBuilder()
+                        .withNodeIdentifier(getNodeIdentifier("uint32InList"))
+                        .withValue(1)
+                        .build())
+                    .withChild(Builders.containerBuilder()
+                        .withNodeIdentifier(getNodeIdentifier("containerInList"))
+                        .build())
+                    .withNodeIdentifier(NodeIdentifierWithPredicates.of(getNodeIdentifier("list").getNodeType(),
+                        getNodeIdentifier("uint32InList").getNodeType(), 1))
+                    .build())
                 .build())
             .withChild(Builders.<Integer>leafBuilder()
                 .withNodeIdentifier(getNodeIdentifier("augmentUint32"))
-                .withValue(11).build());
+                .withValue(11)
+                .build());
 
-        // This works without schema (adding child from augment as a direct
-        // child)
-        builder.withChild(Builders.<Integer>leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32"))
-                .withValue(11).build());
+        // This works without schema (adding child from augment as a direct child)
+        builder.withChild(Builders.<Integer>leafBuilder()
+            .withNodeIdentifier(getNodeIdentifier("augmentUint32"))
+            .withValue(11)
+            .build());
     }
 
     private static <T> NodeWithValue<T> getNodeWithValueIdentifier(final String localName, final T value) {
index 879b0103171191168f33d5cebe33859938abf0f5..8bd551bc8b89c15028448ed78db9d0d0c26db65d 100644 (file)
@@ -8,14 +8,13 @@
 
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
 
-import java.util.Optional;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -24,30 +23,29 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 
 /*
- * Schema structure of document is:
- *
- * container root { 
- *      list list-a {
- *              key leaf-a;
- *              leaf leaf-a;
- *              choice choice-a {
- *                      case one {
- *                              leaf one;
- *                      }
- *                      case two-three {
- *                              leaf two;
- *                              leaf three;
- *                      }
- *              }
- *              list list-b {
- *                      key leaf-b;
- *                      leaf leaf-b;
- *              }
- *      }
- * }
- */
-public class NormalizedNodeUtilsTest {
-
+* Schema structure of document is:
+*
+* container root { 
+*      list list-a {
+*              key leaf-a;
+*              leaf leaf-a;
+*              choice choice-a {
+*                      case one {
+*                              leaf one;
+*                      }
+*                      case two-three {
+*                              leaf two;
+*                              leaf three;
+*                      }
+*              }
+*              list list-b {
+*                      key leaf-b;
+*                      leaf leaf-b;
+*              }
+*      }
+* }
+*/
+class NormalizedNodeUtilsTest {
     private static final QName ROOT_QNAME = QName.create("urn:opendaylight:controller:sal:dom:store:test", "2014-03-13",
             "root");
     private static final QName LIST_A_QNAME = QName.create(ROOT_QNAME, "list-a");
@@ -60,15 +58,15 @@ public class NormalizedNodeUtilsTest {
     private static final String TWO = "two";
 
     private static final YangInstanceIdentifier LIST_A_FOO_PATH = YangInstanceIdentifier.builder()
-                .node(LIST_A_QNAME)
-                .nodeWithKey(LIST_A_QNAME, LEAF_A_QNAME, FOO)
-                .build();
+        .node(LIST_A_QNAME)
+        .nodeWithKey(LIST_A_QNAME, LEAF_A_QNAME, FOO)
+        .build();
     private static final YangInstanceIdentifier LIST_B_TWO_PATH = YangInstanceIdentifier.builder()
-                .node(LIST_A_QNAME)
-                .nodeWithKey(LIST_A_QNAME, LEAF_A_QNAME, BAR)
-                .node(LIST_B_QNAME)
-                .nodeWithKey(LIST_B_QNAME,LEAF_B_QNAME,TWO)
-                .build();
+        .node(LIST_A_QNAME)
+        .nodeWithKey(LIST_A_QNAME, LEAF_A_QNAME, BAR)
+        .node(LIST_B_QNAME)
+        .nodeWithKey(LIST_B_QNAME,LEAF_B_QNAME,TWO)
+        .build();
 
     /**
      * Returns a test document.
@@ -89,30 +87,29 @@ public class NormalizedNodeUtilsTest {
      * @return A test document
      */
     private static NormalizedNode createDocumentOne() {
-        return ImmutableContainerNodeBuilder
-                .create()
-                .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
-                .withChild(
-                        mapNodeBuilder(LIST_A_QNAME)
-                                .withChild(mapEntry(LIST_A_QNAME, LEAF_A_QNAME, FOO))
-                                .withChild(
-                                        mapEntryBuilder(LIST_A_QNAME, LEAF_A_QNAME, BAR).withChild(
-                                                mapNodeBuilder(LIST_B_QNAME)
-                                                        .withChild(mapEntry(LIST_B_QNAME, LEAF_B_QNAME, ONE))
-                                                        .withChild(mapEntry(LIST_B_QNAME, LEAF_B_QNAME, TWO)).build())
-                                                .build()).build()).build();
-
+        return ImmutableContainerNodeBuilder.create()
+            .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
+            .withChild(mapNodeBuilder(LIST_A_QNAME)
+                .withChild(mapEntry(LIST_A_QNAME, LEAF_A_QNAME, FOO))
+                .withChild(mapEntryBuilder(LIST_A_QNAME, LEAF_A_QNAME, BAR)
+                    .withChild(mapNodeBuilder(LIST_B_QNAME)
+                        .withChild(mapEntry(LIST_B_QNAME, LEAF_B_QNAME, ONE))
+                        .withChild(mapEntry(LIST_B_QNAME, LEAF_B_QNAME, TWO))
+                        .build())
+                    .build())
+                .build())
+            .build();
     }
 
     @Test
-    public void findNodeTest() {
-        NormalizedNode tree = createDocumentOne();
+    void findNodeTest() {
+        final var tree = createDocumentOne();
         assertNotNull(tree);
 
-        Optional<NormalizedNode> listFooResult = NormalizedNodes.findNode(tree, LIST_A_FOO_PATH);
+        final var listFooResult = NormalizedNodes.findNode(tree, LIST_A_FOO_PATH);
         assertTrue(listFooResult.isPresent());
 
-        Optional<NormalizedNode> listTwoResult = NormalizedNodes.findNode(tree, LIST_B_TWO_PATH);
+        final var listTwoResult = NormalizedNodes.findNode(tree, LIST_B_TWO_PATH);
         assertTrue(listTwoResult.isPresent());
     }
 }
index afd051d73090bbda664ea83df1bdce1841b308f4..5a2ef01cf0b157d9825e9f4de9bc16e74940b9bd 100644 (file)
@@ -7,25 +7,22 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
 
-public class OrderingEqualityTest {
+class OrderingEqualityTest {
     private static final QName FOO = QName.create("foo", "foo");
     private static final QName BAR = QName.create("foo", "bar");
 
     @Test
-    public void testUserMap() {
-        final UserMapNode firstMap = Builders.orderedMapBuilder()
+    void testUserMap() {
+        final var firstMap = Builders.orderedMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(Builders.mapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
@@ -37,7 +34,7 @@ public class OrderingEqualityTest {
                 .build())
             .build();
 
-        final UserMapNode secondMap = Builders.orderedMapBuilder()
+        final var secondMap = Builders.orderedMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(Builders.mapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
@@ -50,10 +47,10 @@ public class OrderingEqualityTest {
             .build();
 
         assertEquals(firstMap.asMap(), secondMap.asMap());
-        assertFalse(firstMap.equals(secondMap));
-        assertFalse(secondMap.equals(firstMap));
+        assertNotEquals(firstMap, secondMap);
+        assertNotEquals(secondMap, firstMap);
 
-        final UserMapNode thirdMap = Builders.orderedMapBuilder()
+        final var thirdMap = Builders.orderedMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(Builders.mapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
@@ -66,13 +63,13 @@ public class OrderingEqualityTest {
             .build();
 
         assertEquals(secondMap.asMap(), thirdMap.asMap());
-        assertFalse(firstMap.equals(thirdMap));
-        assertTrue(secondMap.equals(thirdMap));
+        assertNotEquals(firstMap, thirdMap);
+        assertEquals(secondMap, thirdMap);
         assertArrayEquals(secondMap.body().toArray(), thirdMap.body().toArray());
         assertEquals(secondMap.hashCode(), thirdMap.hashCode());
 
         // Although this map looks as secondMap, it is not equal
-        final SystemMapNode systemMap = Builders.mapBuilder()
+        final var systemMap = Builders.mapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(Builders.mapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
@@ -85,13 +82,13 @@ public class OrderingEqualityTest {
             .build();
 
         assertEquals(secondMap.asMap(), systemMap.asMap());
-        assertFalse(firstMap.equals(systemMap));
-        assertFalse(secondMap.equals(systemMap));
+        assertNotEquals(firstMap, systemMap);
+        assertNotEquals(secondMap, systemMap);
     }
 
     @Test
-    public void testSystemMap() {
-        final SystemMapNode firstMap = Builders.mapBuilder()
+    void testSystemMap() {
+        final var firstMap = Builders.mapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(Builders.mapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "one"))
@@ -102,7 +99,7 @@ public class OrderingEqualityTest {
                 .withChild(ImmutableNodes.leafNode(BAR, "two"))
                 .build())
             .build();
-        final SystemMapNode secondMap = Builders.mapBuilder()
+        final var secondMap = Builders.mapBuilder()
             .withNodeIdentifier(new NodeIdentifier(FOO))
             .withChild(Builders.mapEntryBuilder()
                 .withNodeIdentifier(NodeIdentifierWithPredicates.of(FOO, BAR, "two"))
@@ -116,8 +113,8 @@ public class OrderingEqualityTest {
 
         assertEquals(firstMap.asMap(), secondMap.asMap());
         // Order does not matter
-        assertTrue(firstMap.equals(secondMap));
-        assertTrue(secondMap.equals(firstMap));
+        assertEquals(firstMap, secondMap);
+        assertEquals(secondMap, firstMap);
         assertEquals(firstMap.hashCode(), secondMap.hashCode());
     }
 }
index 92b4ae43cb38266b7c5e63972028d974ea28d09e..288a4e565a85ea4da8d27fb88363d05c78ceb25b 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
-public class AbstractImmutableNormalizedValueAttrNodeTest {
+class AbstractImmutableNormalizedValueAttrNodeTest {
     private record TestValue(int value) {
         // Simple enough
     }
@@ -28,257 +27,257 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
     @Test
     // This test is based on using different references; we're testing equals()
     @SuppressWarnings({"RedundantStringConstructorCall", "EqualsWithItself"})
-    public void equalsByteTest() {
-        byte[] value = "test".getBytes();
-        byte[] equalValue = "test".getBytes();
+    void equalsByteTest() {
+        final var value = "test".getBytes();
+        final var equalValue = "test".getBytes();
 
-        LeafNode<byte[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
-        LeafNode<byte[]> equalLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue);
+        final var leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
+        final var equalLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue);
 
-        assertTrue(leafNode.equals(leafNode));
-        assertTrue(leafNode.equals(equalLeafNode));
-        assertTrue(equalLeafNode.equals(leafNode));
+        assertEquals(leafNode, leafNode);
+        assertEquals(leafNode, equalLeafNode);
+        assertEquals(equalLeafNode, leafNode);
 
-        TestValue[] value2 = new TestValue[] { new TestValue(1), new TestValue(2) };
-        TestValue[] equalValue2 = new TestValue[] { new TestValue(1), new TestValue(2) };
+        final var value2 = new TestValue[] { new TestValue(1), new TestValue(2) };
+        final var equalValue2 = new TestValue[] { new TestValue(1), new TestValue(2) };
 
-        LeafNode<TestValue[]> leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
-        LeafNode<TestValue[]> equalLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue2);
+        final var leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
+        final var equalLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue2);
 
-        assertTrue(leafNode2.equals(leafNode2));
-        assertTrue(leafNode2.equals(equalLeafNode2));
-        assertTrue(equalLeafNode2.equals(leafNode2));
+        assertEquals(leafNode2, leafNode2);
+        assertEquals(leafNode2, equalLeafNode2);
+        assertEquals(equalLeafNode2, leafNode2);
 
-        byte[][] value3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
-        byte[][] equalValue3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
+        final var value3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
+        final var equalValue3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
 
-        LeafNode<byte[][]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME,
+        final var leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME,
                 value3);
-        LeafNode<byte[][]> equalLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue3);
+        final var equalLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue3);
 
-        assertTrue(leafNode3.equals(leafNode3));
-        assertTrue(leafNode3.equals(equalLeafNode3));
-        assertTrue(equalLeafNode3.equals(leafNode3));
+        assertEquals(leafNode3, leafNode3);
+        assertEquals(leafNode3, equalLeafNode3);
+        assertEquals(equalLeafNode3, leafNode3);
 
-        TestValue[][] value4 = new TestValue[][] {
+        final var value4 = new TestValue[][] {
             new TestValue[] { new TestValue(1), new TestValue(2) },
             new TestValue[] { new TestValue(3), new TestValue(4) },
         };
-        TestValue[][] equalValue4 = new TestValue[][] {
+        final var equalValue4 = new TestValue[][] {
             new TestValue[] { new TestValue(1), new TestValue(2) },
             new TestValue[] { new TestValue(3), new TestValue(4) },
         };
 
-        LeafNode<TestValue[][]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME,value4);
-        LeafNode<TestValue[][]> equalLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue4);
+        final var leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME,value4);
+        final var equalLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue4);
 
-        assertTrue(leafNode4.equals(leafNode4));
-        assertTrue(leafNode4.equals(equalLeafNode4));
-        assertTrue(equalLeafNode4.equals(leafNode4));
+        assertEquals(leafNode4, leafNode4);
+        assertEquals(leafNode4, equalLeafNode4);
+        assertEquals(equalLeafNode4, leafNode4);
 
-        TestValue value6 = new TestValue(1);
-        TestValue equalValue6 = new TestValue(1);
+        final var value6 = new TestValue(1);
+        final var equalValue6 = new TestValue(1);
 
-        LeafNode<TestValue> leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
-        LeafNode<TestValue> equalLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue6);
+        final var leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
+        final var equalLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue6);
 
-        assertTrue(leafNode6.equals(leafNode6));
-        assertTrue(leafNode6.equals(equalLeafNode6));
-        assertTrue(equalLeafNode6.equals(leafNode6));
+        assertEquals(leafNode6, leafNode6);
+        assertEquals(leafNode6, equalLeafNode6);
+        assertEquals(equalLeafNode6, leafNode6);
 
-        String value5 = "test";
-        String equalValue5 = new String("test");
+        final var value5 = "test";
+        final var equalValue5 = new String("test");
 
-        LeafNode<String> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
-        LeafNode<String> equalLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue5);
+        final var leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
+        final var equalLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue5);
 
-        assertTrue(leafNode5.equals(leafNode5));
-        assertTrue(leafNode5.equals(equalLeafNode5));
-        assertTrue(equalLeafNode5.equals(leafNode5));
+        assertEquals(leafNode5, leafNode5);
+        assertEquals(leafNode5, equalLeafNode5);
+        assertEquals(equalLeafNode5, leafNode5);
     }
 
     @Test
     // We're testing equals()
     @SuppressWarnings({"ObjectEqualsNull", "EqualsBetweenInconvertibleTypes"})
-    public void notEqualByteTest() {
+    void notEqualByteTest() {
 
-        byte[] value = "test".getBytes();
-        byte[] equalValue = "test".getBytes();
+        final var value = "test".getBytes();
+        final var equalValue = "test".getBytes();
 
-        LeafNode<byte[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
-        LeafNode<byte[]> otherLeafNode = ImmutableNodes.leafNode(OTHER_LEAF_QNAME, equalValue);
+        final var leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
+        final var otherLeafNode = ImmutableNodes.leafNode(OTHER_LEAF_QNAME, equalValue);
 
-        assertFalse(leafNode.equals(null));
-        assertFalse(leafNode.equals(new Object()));
-        assertFalse(leafNode.equals(otherLeafNode));
-        assertFalse(otherLeafNode.equals(leafNode));
+        assertNotEquals(null, leafNode);
+        assertNotEquals(leafNode, new Object());
+        assertNotEquals(leafNode, otherLeafNode);
+        assertNotEquals(otherLeafNode, leafNode);
 
-        byte[] value1 = "test".getBytes();
-        byte[] otherValue1 = "test1".getBytes();
+        final var value1 = "test".getBytes();
+        final var otherValue1 = "test1".getBytes();
 
-        LeafNode<byte[]> leafNode1 = ImmutableNodes.leafNode(LEAF_QNAME, value1);
-        LeafNode<byte[]> otherLeafNode1 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue1);
+        final var leafNode1 = ImmutableNodes.leafNode(LEAF_QNAME, value1);
+        final var otherLeafNode1 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue1);
 
-        assertFalse(leafNode1.equals(otherLeafNode1));
-        assertFalse(otherLeafNode1.equals(leafNode1));
+        assertNotEquals(leafNode1, otherLeafNode1);
+        assertNotEquals(otherLeafNode1, leafNode1);
 
-        TestValue[] value2 = new TestValue[] { new TestValue(1), new TestValue(1) };
-        TestValue[] otherValue2 = new TestValue[] { new TestValue(1), new TestValue(2) };
+        final var value2 = new TestValue[] { new TestValue(1), new TestValue(1) };
+        final var otherValue2 = new TestValue[] { new TestValue(1), new TestValue(2) };
 
-        LeafNode<TestValue[]> leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
-        LeafNode<TestValue[]> otherLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue2);
+        final var leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
+        final var otherLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue2);
 
-        assertFalse(leafNode2.equals(otherLeafNode2));
-        assertFalse(otherLeafNode2.equals(leafNode2));
+        assertNotEquals(leafNode2, otherLeafNode2);
+        assertNotEquals(otherLeafNode2, leafNode2);
 
-        byte[][] value3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
-        byte[][] otherValue3 = new byte[][] { "test".getBytes(), "test3".getBytes() };
+        final var value3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
+        final var otherValue3 = new byte[][] { "test".getBytes(), "test3".getBytes() };
 
-        LeafNode<byte[][]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME, value3);
-        LeafNode<byte[][]> otherLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue3);
+        final var leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME, value3);
+        final var otherLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue3);
 
-        assertFalse(leafNode3.equals(otherLeafNode3));
-        assertFalse(otherLeafNode3.equals(leafNode3));
+        assertNotEquals(leafNode3, otherLeafNode3);
+        assertNotEquals(otherLeafNode3, leafNode3);
 
-        TestValue[][] value4 = new TestValue[][] {
+        final var value4 = new TestValue[][] {
             new TestValue[] { new TestValue(1), new TestValue(2) },
             new TestValue[] { new TestValue(3), new TestValue(4) },
         };
-        TestValue[][] otherValue4 = new TestValue[][] {
+        final var otherValue4 = new TestValue[][] {
             new TestValue[] { new TestValue(1), new TestValue(2) },
             new TestValue[] { new TestValue(3), new TestValue(5) },
         };
 
-        LeafNode<TestValue[][]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME, value4);
-        LeafNode<TestValue[][]> otherLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue4);
+        final var leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME, value4);
+        final var otherLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue4);
 
-        assertFalse(leafNode4.equals(otherLeafNode4));
-        assertFalse(otherLeafNode4.equals(leafNode4));
+        assertNotEquals(leafNode4, otherLeafNode4);
+        assertNotEquals(otherLeafNode4, leafNode4);
 
-        TestValue value6 = new TestValue(1);
-        TestValue otherValue6 = new TestValue(2);
+        final var value6 = new TestValue(1);
+        final var otherValue6 = new TestValue(2);
 
-        LeafNode<TestValue> leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
-        LeafNode<TestValue> otherLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue6);
+        final var leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
+        final var otherLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue6);
 
-        assertFalse(leafNode6.equals(otherLeafNode6));
-        assertFalse(otherLeafNode6.equals(leafNode6));
+        assertNotEquals(leafNode6, otherLeafNode6);
+        assertNotEquals(otherLeafNode6, leafNode6);
 
-        String value5 = "test";
-        String otherValue5 = "test2";
+        final var value5 = "test";
+        final var otherValue5 = "test2";
 
-        LeafNode<String> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
-        LeafNode<String> otherLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue5);
+        final var leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
+        final var otherLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue5);
 
-        assertFalse(leafNode5.equals(otherLeafNode5));
-        assertFalse(otherLeafNode5.equals(leafNode5));
-        assertFalse(leafNode5.equals(leafNode));
-        assertFalse(leafNode5.equals(leafNode1));
-        assertFalse(leafNode5.equals(leafNode2));
-        assertFalse(leafNode5.equals(leafNode3));
-        assertFalse(leafNode5.equals(leafNode4));
-        assertFalse(leafNode5.equals(leafNode6));
-        assertFalse(leafNode.equals(leafNode5));
-        assertFalse(leafNode1.equals(leafNode5));
-        assertFalse(leafNode2.equals(leafNode5));
-        assertFalse(leafNode3.equals(leafNode5));
-        assertFalse(leafNode4.equals(leafNode5));
-        assertFalse(leafNode6.equals(leafNode5));
+        assertNotEquals(leafNode5, otherLeafNode5);
+        assertNotEquals(otherLeafNode5, leafNode5);
+        assertNotEquals(leafNode5, leafNode);
+        assertNotEquals(leafNode5, leafNode1);
+        assertNotEquals(leafNode5, leafNode2);
+        assertNotEquals(leafNode5, leafNode3);
+        assertNotEquals(leafNode5, leafNode4);
+        assertNotEquals(leafNode5, leafNode6);
+        assertNotEquals(leafNode, leafNode5);
+        assertNotEquals(leafNode1, leafNode5);
+        assertNotEquals(leafNode2, leafNode5);
+        assertNotEquals(leafNode3, leafNode5);
+        assertNotEquals(leafNode4, leafNode5);
+        assertNotEquals(leafNode6, leafNode5);
 
-        byte[] byteValue = new byte[] { 1, 1 };
+        final var byteValue = new byte[] { 1, 1 };
 
-        LeafNode<byte[]> byteLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, byteValue);
-        assertFalse(byteLeafNode.equals(leafNode2));
-        assertFalse(leafNode2.equals(byteLeafNode));
+        final var byteLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, byteValue);
+        assertNotEquals(byteLeafNode, leafNode2);
+        assertNotEquals(leafNode2, byteLeafNode);
     }
 
     @Test
     // We're testing equals()
     @SuppressWarnings({"EqualsWithItself", "EqualsBetweenInconvertibleTypes"})
-    public void equalsOtherTypesTest() {
+    void equalsOtherTypesTest() {
 
-        char[] valueChar = "test".toCharArray();
-        char[] equalValueChar = "test".toCharArray();
+        final var valueChar = "test".toCharArray();
+        final var equalValueChar = "test".toCharArray();
 
-        LeafNode<char[]> leafNodeChar = ImmutableNodes.leafNode(LEAF_QNAME, valueChar);
-        LeafNode<char[]> equalLeafNodeChar = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValueChar);
+        final var leafNodeChar = ImmutableNodes.leafNode(LEAF_QNAME, valueChar);
+        final var equalLeafNodeChar = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValueChar);
 
-        assertTrue(leafNodeChar.equals(leafNodeChar));
-        assertTrue(leafNodeChar.equals(equalLeafNodeChar));
-        assertTrue(equalLeafNodeChar.equals(leafNodeChar));
+        assertEquals(leafNodeChar, leafNodeChar);
+        assertEquals(leafNodeChar, equalLeafNodeChar);
+        assertEquals(equalLeafNodeChar, leafNodeChar);
 
-        boolean[] value = new boolean[] { true, false };
-        boolean[] equalValue = new boolean[] { true, false };
+        final var value = new boolean[] { true, false };
+        final var equalValue = new boolean[] { true, false };
 
-        LeafNode<boolean[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
-        LeafNode<boolean[]> equalLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue);
+        final var leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
+        final var equalLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue);
 
-        assertTrue(leafNode.equals(leafNode));
-        assertTrue(leafNode.equals(equalLeafNode));
-        assertTrue(equalLeafNode.equals(leafNode));
+        assertEquals(leafNode, leafNode);
+        assertEquals(leafNode, equalLeafNode);
+        assertEquals(equalLeafNode, leafNode);
 
-        int[] value2 = new int[] { 1, 2 };
-        int[] equalValue2 = new int[] { 1, 2 };
+        final var value2 = new int[] { 1, 2 };
+        final var equalValue2 = new int[] { 1, 2 };
 
-        LeafNode<int[]> leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
-        LeafNode<int[]> equalLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue2);
+        final var leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
+        final var equalLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue2);
 
-        assertTrue(leafNode2.equals(leafNode2));
-        assertTrue(leafNode2.equals(equalLeafNode2));
-        assertTrue(equalLeafNode2.equals(leafNode2));
+        assertEquals(leafNode2, leafNode2);
+        assertEquals(leafNode2, equalLeafNode2);
+        assertEquals(equalLeafNode2, leafNode2);
 
-        short[] value3 = new short[] { 1, 2 };
-        short[] equalValue3 = new short[] { 1, 2 };
+        final var value3 = new short[] { 1, 2 };
+        final var equalValue3 = new short[] { 1, 2 };
 
-        LeafNode<short[]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME, value3);
-        LeafNode<short[]> equalLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue3);
+        final var leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME, value3);
+        final var equalLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue3);
 
-        assertTrue(leafNode3.equals(leafNode3));
-        assertTrue(leafNode3.equals(equalLeafNode3));
-        assertTrue(equalLeafNode3.equals(leafNode3));
+        assertEquals(leafNode3, leafNode3);
+        assertEquals(leafNode3, equalLeafNode3);
+        assertEquals(equalLeafNode3, leafNode3);
 
-        long[] value4 = new long[] { 1, 2 };
-        long[] equalValue4 = new long[] { 1, 2 };
+        final var value4 = new long[] { 1, 2 };
+        final var equalValue4 = new long[] { 1, 2 };
 
-        LeafNode<long[]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME, value4);
-        LeafNode<long[]> equalLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue4);
+        final var leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME, value4);
+        final var equalLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue4);
 
-        assertTrue(leafNode4.equals(leafNode4));
-        assertTrue(leafNode4.equals(equalLeafNode4));
-        assertTrue(equalLeafNode4.equals(leafNode4));
+        assertEquals(leafNode4, leafNode4);
+        assertEquals(leafNode4, equalLeafNode4);
+        assertEquals(equalLeafNode4, leafNode4);
 
-        double[] value6 = new double[] { 1, 2 };
-        double[] equalValue6 = new double[] { 1, 2 };
+        final var value6 = new double[] { 1, 2 };
+        final var equalValue6 = new double[] { 1, 2 };
 
-        LeafNode<double[]> leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
-        LeafNode<double[]> equalLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue6);
+        final var leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
+        final var equalLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue6);
 
-        assertTrue(leafNode6.equals(leafNode6));
-        assertTrue(leafNode6.equals(equalLeafNode6));
-        assertTrue(equalLeafNode6.equals(leafNode6));
+        assertEquals(leafNode6, leafNode6);
+        assertEquals(leafNode6, equalLeafNode6);
+        assertEquals(equalLeafNode6, leafNode6);
 
-        float[] value5 = new float[] { 1, 2 };
-        float[] equalValue5 = new float[] { 1, 2 };
+        final var value5 = new float[] { 1, 2 };
+        final var equalValue5 = new float[] { 1, 2 };
 
-        LeafNode<float[]> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
-        LeafNode<float[]> equalLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue5);
+        final var leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
+        final var equalLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue5);
 
-        assertTrue(leafNode5.equals(leafNode5));
-        assertTrue(leafNode5.equals(equalLeafNode5));
-        assertTrue(equalLeafNode5.equals(leafNode5));
+        assertEquals(leafNode5, leafNode5);
+        assertEquals(leafNode5, equalLeafNode5);
+        assertEquals(equalLeafNode5, leafNode5);
 
-        assertFalse(leafNode.equals(leafNode5));
-        assertFalse(leafNode2.equals(leafNode5));
-        assertFalse(leafNode3.equals(leafNode5));
-        assertFalse(leafNode4.equals(leafNode5));
-        assertFalse(leafNodeChar.equals(leafNode5));
-        assertFalse(leafNode6.equals(leafNode5));
+        assertNotEquals(leafNode, leafNode5);
+        assertNotEquals(leafNode2, leafNode5);
+        assertNotEquals(leafNode3, leafNode5);
+        assertNotEquals(leafNode4, leafNode5);
+        assertNotEquals(leafNodeChar, leafNode5);
+        assertNotEquals(leafNode6, leafNode5);
 
-        assertFalse(leafNode5.equals(leafNode));
-        assertFalse(leafNode5.equals(leafNode2));
-        assertFalse(leafNode5.equals(leafNode3));
-        assertFalse(leafNode5.equals(leafNode4));
-        assertFalse(leafNode5.equals(leafNodeChar));
-        assertFalse(leafNode5.equals(leafNode6));
+        assertNotEquals(leafNode5, leafNode);
+        assertNotEquals(leafNode5, leafNode2);
+        assertNotEquals(leafNode5, leafNode3);
+        assertNotEquals(leafNode5, leafNode4);
+        assertNotEquals(leafNode5, leafNodeChar);
+        assertNotEquals(leafNode5, leafNode6);
     }
 }
index 3d69a57b9f38e19d5b577dc74ca75c9ed35258e1..8d7d23a480ff42c7b0fcecc62e7bfa2072f505c8 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
 import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
@@ -25,13 +25,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class YT1417Test {
+@ExtendWith(MockitoExtension.class)
+class YT1417Test {
     public static final QName FOO = QName.create("foo", "foo");
     public static final QName BAR = QName.create("foo", "bar");
 
     @Test
-    public void testContainerNodeEquality() {
+    void testContainerNodeEquality() {
         final var mock = mock(ContainerNode.class);
         doReturn(new NodeIdentifier(FOO)).when(mock).name();
         doReturn(1).when(mock).size();
@@ -63,7 +63,7 @@ public class YT1417Test {
     }
 
     @Test
-    public void testSystemLeafSetNodeEquality() {
+    void testSystemLeafSetNodeEquality() {
         final var mock = mock(SystemLeafSetNode.class);
         doReturn(new NodeIdentifier(FOO)).when(mock).name();
         doReturn(1).when(mock).size();
@@ -113,7 +113,7 @@ public class YT1417Test {
     }
 
     @Test
-    public void testUserLeafSetNodeEquality() {
+    void testUserLeafSetNodeEquality() {
         final var mock = mock(UserLeafSetNode.class);
         doReturn(new NodeIdentifier(FOO)).when(mock).name();
         doReturn(List.of(