Migrate binding-generator to JUnit5 20/115120/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Feb 2025 11:05:35 +0000 (12:05 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Feb 2025 12:07:23 +0000 (13:07 +0100)
This is the last holdout of JUnit4, migrate it.

Change-Id: Ib63ecc67c6d38d384552b10fb4948420533f3b86
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
58 files changed:
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/BindingGeneratorUtilTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/ActionsTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/AugmentRelativeXPathTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/AugmentedTypeTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/BinaryTypeTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/BindingGeneratorImplTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/BitAndUnionTOEnclosingTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Bug4145Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Bug6135Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/ChoiceCaseGenTypesTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/ControllerTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/ExtendedTypedefTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GenEnumResolvingTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GenTypesSubSetTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GenerateInnerClassForBitsAndUnionInLeavesTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GeneratedTypesBitsTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GeneratedTypesLeafrefTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GeneratedTypesStringTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/GeneratedTypesTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/IdentityrefTypeTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/LeafrefResolutionTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal182Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal300Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal302Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal320Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal324Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal332Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal335Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal352Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal406TypeObjectTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal437Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal438Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal458Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal459Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal499Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal500Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal506Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal516Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal517Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal519Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal531Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal552Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal554Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal572Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal573Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal600Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal666Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal675Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal715Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal718Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal810Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal824Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/Mdsal829Test.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/SerialVersionHelperTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/SupportTestUtil.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/UnionTypeDefTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/UsesTest.java
binding/binding-generator/src/test/java/org/opendaylight/yangtools/binding/generator/impl/reactor/GeneratorTest.java

index 392ed914b94ec9a2f48e418ee339ac12806277e8..db8082480e53ae51ccf820dcb107b9d1f14759c0 100644 (file)
@@ -7,25 +7,24 @@
  */
 package org.opendaylight.yangtools.binding.generator;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.Range;
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.Restrictions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.ValueRange;
-import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.Int16TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.Uint16TypeDefinition;
@@ -33,22 +32,24 @@ import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.ri.type.DerivedTypes;
 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;
 
-public class BindingGeneratorUtilTest {
+@ExtendWith(MockitoExtension.class)
+class BindingGeneratorUtilTest {
     private static final QName ROOT = QName.create("test", "root");
 
-    @Test
-    public void getRestrictionsTest() throws InvalidLengthConstraintException {
-        final PatternConstraint constraint = mock(PatternConstraint.class);
+    @Mock
+    private PatternConstraint constraint;
+    @Mock
+    private ConstraintMetaDefinition constraintMeta;
 
-        final StringTypeBuilder builder =
-                RestrictedTypes.newStringBuilder(BaseTypes.stringType(), ROOT);
+    @Test
+    void getRestrictionsTest() throws InvalidLengthConstraintException {
+        final var builder = RestrictedTypes.newStringBuilder(BaseTypes.stringType(), ROOT);
 
         builder.addPatternConstraint(constraint);
-        builder.setLengthConstraint(mock(ConstraintMetaDefinition.class), List.of(ValueRange.of(1, 2)));
+        builder.setLengthConstraint(constraintMeta, List.of(ValueRange.of(1, 2)));
 
-        Restrictions restrictions = BindingGeneratorUtil.getRestrictions(builder.build());
+        final var restrictions = BindingGeneratorUtil.getRestrictions(builder.build());
 
         assertNotNull(restrictions);
         assertEquals(Set.of(Range.closed(1, 2)),
@@ -57,50 +58,50 @@ public class BindingGeneratorUtilTest {
         assertEquals(1, restrictions.getPatternConstraints().size());
 
         assertFalse(restrictions.isEmpty());
-        assertThat(restrictions.getPatternConstraints(), contains(constraint));
+        assertThat(restrictions.getPatternConstraints()).contains(constraint);
     }
 
     @Test
-    public void getEmptyRestrictionsTest() {
-        final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(BaseTypes.stringType(), ROOT).build();
-        final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+    void getEmptyRestrictionsTest() {
+        final var type = DerivedTypes.derivedTypeBuilder(BaseTypes.stringType(), ROOT).build();
+        final var restrictions = BindingGeneratorUtil.getRestrictions(type);
 
         assertNotNull(restrictions);
         assertTrue(restrictions.isEmpty());
     }
 
     @Test
-    public void getDefaultIntegerRestrictionsTest() {
-        final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(BaseTypes.int16Type(), ROOT).build();
-        final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+    void getDefaultIntegerRestrictionsTest() {
+        final var type = DerivedTypes.derivedTypeBuilder(BaseTypes.int16Type(), ROOT).build();
+        final var restrictions = BindingGeneratorUtil.getRestrictions(type);
 
         assertNotNull(restrictions);
         assertFalse(restrictions.isEmpty());
-        assertEquals(((Int16TypeDefinition) type.getBaseType()).getRangeConstraint(),
+        assertEquals(assertInstanceOf(Int16TypeDefinition.class, type.getBaseType()).getRangeConstraint(),
                 restrictions.getRangeConstraint());
         assertEquals(Optional.empty(), restrictions.getLengthConstraint());
         assertEquals(List.of(), restrictions.getPatternConstraints());
     }
 
     @Test
-    public void getDefaultUnsignedIntegerRestrictionsTest() {
-        final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(BaseTypes.uint16Type(), ROOT).build();
-        final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+    void getDefaultUnsignedIntegerRestrictionsTest() {
+        final var type = DerivedTypes.derivedTypeBuilder(BaseTypes.uint16Type(), ROOT).build();
+        final var restrictions = BindingGeneratorUtil.getRestrictions(type);
 
         assertNotNull(restrictions);
         assertFalse(restrictions.isEmpty());
-        assertEquals(((Uint16TypeDefinition) type.getBaseType()).getRangeConstraint(),
+        assertEquals(assertInstanceOf(Uint16TypeDefinition.class, type.getBaseType()).getRangeConstraint(),
                 restrictions.getRangeConstraint());
         assertEquals(Optional.empty(), restrictions.getLengthConstraint());
         assertEquals(List.of(), restrictions.getPatternConstraints());
     }
 
     @Test
-    public void getDefaultDecimalRestrictionsTest() {
-        final DecimalTypeDefinition base = BaseTypes.decimalTypeBuilder(ROOT).setFractionDigits(10).build();
-        final TypeDefinition<?> type = DerivedTypes.derivedTypeBuilder(base, ROOT).build();
+    void getDefaultDecimalRestrictionsTest() {
+        final var base = BaseTypes.decimalTypeBuilder(ROOT).setFractionDigits(10).build();
+        final var type = DerivedTypes.derivedTypeBuilder(base, ROOT).build();
 
-        final Restrictions restrictions = BindingGeneratorUtil.getRestrictions(type);
+        final var restrictions = BindingGeneratorUtil.getRestrictions(type);
 
         assertNotNull(restrictions);
         assertFalse(restrictions.isEmpty());
@@ -110,8 +111,8 @@ public class BindingGeneratorUtilTest {
     }
 
     @Test
-    public void unicodeCharReplaceTest() {
-        String inputString = "abcu\\uuuuu\\uuua\\u\\\\uabc\\\\uuuu\\\\\\uuuu\\\\\\\\uuuu///uu/u/u/u/u/u/u";
+    void unicodeCharReplaceTest() {
+        final var inputString = "abcu\\uuuuu\\uuua\\u\\\\uabc\\\\uuuu\\\\\\uuuu\\\\\\\\uuuu///uu/u/u/u/u/u/u";
 
         assertEquals("abcu\\\\uuuuu\\\\uuua\\\\u\\\\uabc\\\\uuuu\\\\uuuu\\\\uuuu///uu/u/u/u/u/u/u",
             BindingGeneratorUtil.replaceAllIllegalChars(inputString));
index 9b4de90776a8865b83a2b2419f87bcd8a6f3d09c..64f02eb2e89803d8f3e215e9487750b06bd467fe 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class ActionsTest {
+class ActionsTest {
     @Test
-    public void actionsTypeTest() {
+    void actionsTypeTest() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/actions.yang"));
         assertNotNull(generateTypes);
index c900c02a6ea8e1ce92f2e33635966737b43db20b..40730bb9f7c90673ecc3d46a9ab5a6786b8b2d0e 100644 (file)
@@ -7,27 +7,24 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.contract.Naming;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class AugmentRelativeXPathTest {
+class AugmentRelativeXPathTest {
     @Test
-    public void testAugmentationWithRelativeXPath() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+    void testAugmentationWithRelativeXPath() {
+        final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/augment-relative-xpath-models"));
-        assertNotNull("genTypes is null", genTypes);
+        assertNotNull(genTypes);
         assertEquals(27, genTypes.size());
 
         GeneratedTransferObject gtInterfaceKey = null;
@@ -35,38 +32,38 @@ public class AugmentRelativeXPathTest {
         GeneratedType gtTunnel = null;
         GeneratedTransferObject gtTunnelKey = null;
 
-        for (final GeneratedType type : genTypes) {
+        for (var type : genTypes) {
             if (!type.getPackageName().contains("augment._abstract.topology")) {
                 continue;
             }
 
             if (type.getName().equals("InterfaceKey")) {
-                gtInterfaceKey = (GeneratedTransferObject) type;
+                gtInterfaceKey = assertInstanceOf(GeneratedTransferObject.class, type);
 
-                final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
-                assertNotNull("InterfaceKey properties are null", properties);
+                final var properties = gtInterfaceKey.getProperties();
+                assertNotNull(properties, "InterfaceKey properties are null");
                 assertEquals(1, properties.size());
 
-                final GeneratedProperty property = properties.getFirst();
+                final var property = properties.getFirst();
                 assertEquals("interfaceId", property.getName());
-                assertNotNull("interfaceId return type is null", property.getReturnType());
+                assertNotNull(property.getReturnType(), "interfaceId return type is null");
                 assertEquals(JavaTypeName.create(String.class), property.getReturnType().getIdentifier());
             } else if (type.getName().equals("Interface")) {
                 gtInterface = type;
 
-                final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
-                assertNotNull("Interface methods are null", gtInterfaceMethods);
+                final var gtInterfaceMethods = gtInterface.getMethodDefinitions();
+                assertNotNull(gtInterfaceMethods, "Interface methods are null");
                 assertEquals(9, gtInterfaceMethods.size());
 
                 MethodSignature getIfcKeyMethod = null;
-                for (final MethodSignature method : gtInterfaceMethods) {
+                for (var method : gtInterfaceMethods) {
                     if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
                         getIfcKeyMethod = method;
                         break;
                     }
                 }
-                assertNotNull("getKey method is null", getIfcKeyMethod);
-                assertNotNull("getKey method return type is null", getIfcKeyMethod.getReturnType());
+                assertNotNull(getIfcKeyMethod, "getKey method is null");
+                assertNotNull(getIfcKeyMethod.getReturnType(), "getKey method return type is null");
                 assertEquals(JavaTypeName.create(
                     "org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology.rev130503.topology.interfaces",
                     "InterfaceKey"),
@@ -74,43 +71,41 @@ public class AugmentRelativeXPathTest {
             } else if (type.getName().equals("Tunnel")) {
                 gtTunnel = type;
 
-                final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
-                assertNotNull("Tunnel methods are null", tunnelMethods);
+                final var tunnelMethods = gtTunnel.getMethodDefinitions();
+                assertNotNull(tunnelMethods, "Tunnel methods are null");
                 assertEquals(7, tunnelMethods.size());
 
                 MethodSignature getTunnelKeyMethod = null;
-                for (MethodSignature method : tunnelMethods) {
+                for (var method : tunnelMethods) {
                     if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
                         getTunnelKeyMethod = method;
                         break;
                     }
                 }
-                assertNotNull("getKey method is null", getTunnelKeyMethod);
-                assertNotNull("getKey method return type", getTunnelKeyMethod.getReturnType());
+                assertNotNull(getTunnelKeyMethod, "getKey method is null");
+                assertNotNull(getTunnelKeyMethod.getReturnType(), "getKey method return type");
                 assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology"
                     + ".rev130503.topology.network.links.network.link.tunnels", "TunnelKey"),
                     getTunnelKeyMethod.getReturnType().getIdentifier());
             } else if (type.getName().equals("TunnelKey")) {
-                assertThat(type, instanceOf(GeneratedTransferObject.class));
+                gtTunnelKey = assertInstanceOf(GeneratedTransferObject.class, type);
 
-                gtTunnelKey = (GeneratedTransferObject) type;
-
-                final List<GeneratedProperty> properties = gtTunnelKey.getProperties();
-                assertNotNull("TunnelKey properties are null", properties);
+                final var properties = gtTunnelKey.getProperties();
+                assertNotNull(properties, "TunnelKey properties are null");
                 assertEquals(1, properties.size());
 
-                final GeneratedProperty property = properties.getFirst();
+                final var property = properties.getFirst();
                 assertEquals("tunnelId", property.getName());
-                assertNotNull("tunnelId return type is null", property.getReturnType());
+                assertNotNull(property.getReturnType(), "tunnelId return type is null");
                 assertEquals(
                     JavaTypeName.create("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208", "Uri"),
                     property.getReturnType().getIdentifier());
             }
         }
 
-        assertNotNull("Interface is null", gtInterface);
-        assertNotNull("InterfaceKey is null", gtInterfaceKey);
-        assertNotNull("Tunnel is null", gtTunnel);
-        assertNotNull("TunnelKey is null", gtTunnelKey);
+        assertNotNull(gtInterface, "Interface is null");
+        assertNotNull(gtInterfaceKey, "InterfaceKey is null");
+        assertNotNull(gtTunnel, "Tunnel is null");
+        assertNotNull(gtTunnelKey, "TunnelKey is null");
     }
 }
index b801f9c8ddda2107bcd4a66bc8059be661ac4e68..9cc165a79b46d0452d31a510328522f8aaa496ba 100644 (file)
@@ -7,13 +7,11 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.contract.Naming;
 import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
@@ -21,21 +19,19 @@ import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.binding.model.ri.Types;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class AugmentedTypeTest {
+class AugmentedTypeTest {
     @Test
-    public void augmentedAbstractTopologyTest() {
-        final EffectiveModelContext context = YangParserTestUtils.parseYangResources(AugmentedTypeTest.class,
+    void augmentedAbstractTopologyTest() {
+        final var context = YangParserTestUtils.parseYangResources(AugmentedTypeTest.class,
             "/augment-test-models/abstract-topology@2013-02-08.yang",
             "/augment-test-models/augment-abstract-topology@2013-05-03.yang",
             "/augment-test-models/augment-network-link-attributes@2013-05-03.yang",
             "/augment-test-models/augment-topology-tunnels@2013-05-03.yang",
             "/augment-test-models/ietf-interfaces@2012-11-15.yang");
-        assertNotNull("Schema Context is null", context);
 
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(context);
+        final var genTypes = DefaultBindingGenerator.generateFor(context);
         assertEquals(31, genTypes.size());
 
         GeneratedTransferObject gtInterfaceKey = null;
@@ -44,28 +40,28 @@ public class AugmentedTypeTest {
         GeneratedTransferObject gtTunnelKey = null;
         GeneratedType gtNetworkLink2 = null;
 
-        for (final GeneratedType type : genTypes) {
+        for (var type : genTypes) {
             if (!type.getPackageName().contains("augment._abstract.topology")) {
                 continue;
             }
 
             if (type.getName().equals("InterfaceKey")) {
-                gtInterfaceKey = (GeneratedTransferObject) type;
+                gtInterfaceKey = assertInstanceOf(GeneratedTransferObject.class, type);
             } else if (type.getName().equals("Interface")) {
                 gtInterface = type;
             } else if (type.getName().equals("Tunnel")) {
                 gtTunnel = type;
             } else if (type.getName().equals("TunnelKey")) {
-                gtTunnelKey = (GeneratedTransferObject) type;
+                gtTunnelKey = assertInstanceOf(GeneratedTransferObject.class, type);
             } else if (type.getName().equals("NetworkLink2")) {
                 gtNetworkLink2 = type;
             }
         }
 
         // 'Interface
-        assertNotNull("gtInterface is null", gtInterface);
-        final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
-        assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
+        assertNotNull(gtInterface, "gtInterface is null");
+        final var gtInterfaceMethods = gtInterface.getMethodDefinitions();
+        assertNotNull(gtInterfaceMethods, "gtInterfaceMethods is null");
         MethodSignature getIfcKeyMethod = null;
         for (final MethodSignature method : gtInterfaceMethods) {
             if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
@@ -73,83 +69,82 @@ public class AugmentedTypeTest {
                 break;
             }
         }
-        assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);
-        assertThat(getIfcKeyMethod.getReturnType(), instanceOf(GeneratedTransferObject.class));
+        assertNotNull(getIfcKeyMethod, "getIfcKeyMethod is null");
+        var retType = assertInstanceOf(GeneratedTransferObject.class, getIfcKeyMethod.getReturnType());
         assertEquals(JavaTypeName.create(
             "org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology.rev130503.topology.interfaces",
-            "InterfaceKey"), getIfcKeyMethod.getReturnType().getIdentifier());
+            "InterfaceKey"), retType.getIdentifier());
 
         MethodSignature getHigherLayerIfMethod = null;
-        for (final MethodSignature method : gtInterfaceMethods) {
+        for (var method : gtInterfaceMethods) {
             if (method.getName().equals("getHigherLayerIf")) {
                 getHigherLayerIfMethod = method;
                 break;
             }
         }
-        assertNotNull("getHigherLayerIf method is null", getHigherLayerIfMethod);
+        assertNotNull(getHigherLayerIfMethod, "getHigherLayerIf method is null");
         assertEquals(Types.setTypeFor(Types.STRING), getHigherLayerIfMethod.getReturnType());
 
         // 'InterfaceKey'
-        assertNotNull("InterfaceKey is null", gtInterfaceKey);
-        final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
-        assertNotNull("properties is null", properties);
+        assertNotNull(gtInterfaceKey, "InterfaceKey is null");
+        final var properties = gtInterfaceKey.getProperties();
+        assertNotNull(properties, "properties is null");
         GeneratedProperty gtInterfaceId = null;
-        for (final GeneratedProperty property : properties) {
+        for (var property : properties) {
             if (property.getName().equals("interfaceId")) {
                 gtInterfaceId = property;
                 break;
             }
         }
-        assertNotNull("interfaceId is null", gtInterfaceId);
+        assertNotNull(gtInterfaceId, "interfaceId is null");
         assertEquals(Types.STRING, gtInterfaceId.getReturnType());
 
         // 'Tunnel'
-        assertNotNull("Tunnel is null", gtTunnel);
-        final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
-        assertNotNull("Tunnel methods are null", tunnelMethods);
+        assertNotNull(gtTunnel, "Tunnel is null");
+        final var tunnelMethods = gtTunnel.getMethodDefinitions();
+        assertNotNull(tunnelMethods, "Tunnel methods are null");
         MethodSignature getTunnelKeyMethod = null;
-        for (MethodSignature method : tunnelMethods) {
+        for (var method : tunnelMethods) {
             if (Naming.KEY_AWARE_KEY_NAME.equals(method.getName())) {
                 getTunnelKeyMethod = method;
                 break;
             }
         }
-        assertNotNull("getKey method of Tunnel is null", getTunnelKeyMethod);
+        assertNotNull(getTunnelKeyMethod, "getKey method of Tunnel is null");
 
-        var retType = getTunnelKeyMethod.getReturnType();
-        assertThat(retType, instanceOf(GeneratedTransferObject.class));
+        retType = assertInstanceOf(GeneratedTransferObject.class, getTunnelKeyMethod.getReturnType());
         assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.urn.model.augment._abstract.topology.rev130503"
             + ".topology.network.links.network.link.tunnels", "TunnelKey"), retType.getIdentifier());
 
         // 'TunnelKey'
-        assertNotNull("TunnelKey is null", gtTunnelKey);
-        final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
-        assertNotNull("TunnelKey properties are null", tunnelKeyProperties);
+        assertNotNull(gtTunnelKey, "TunnelKey is null");
+        final var tunnelKeyProperties = gtTunnelKey.getProperties();
+        assertNotNull(tunnelKeyProperties, "TunnelKey properties are null");
 
         GeneratedProperty gtTunnelId = null;
-        for (final GeneratedProperty property : tunnelKeyProperties) {
+        for (var property : tunnelKeyProperties) {
             if (property.getName().equals("tunnelId")) {
                 gtTunnelId = property;
             }
         }
-        assertNotNull("tunnelId is null", gtTunnelId);
+        assertNotNull(gtTunnelId, "tunnelId is null");
         assertEquals(Types.typeForClass(Integer.class), gtTunnelId.getReturnType());
 
         // 'NetworkLink2'
-        assertNotNull("NetworkLink2 is null", gtNetworkLink2);
+        assertNotNull(gtNetworkLink2, "NetworkLink2 is null");
 
-        final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
-        assertNotNull("NetworkLink2 methods are null", networkLink2Methods);
+        final var networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
+        assertNotNull(networkLink2Methods, "NetworkLink2 methods are null");
 
         MethodSignature getIfcMethod = null;
-        for (MethodSignature method : networkLink2Methods) {
+        for (var method : networkLink2Methods) {
             if (method.getName().equals("getInterface")) {
                 getIfcMethod = method;
                 break;
             }
         }
 
-        assertNotNull("getInterface method is null", getIfcMethod);
+        assertNotNull(getIfcMethod, "getInterface method is null");
         assertEquals(Types.STRING, getIfcMethod.getReturnType());
     }
 }
index a7a20cb2201c304e3d19e7e0a259d748db92934f..2b67ea64a2c5d5d621a73ca9a5e61bd8cbc14c80 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class BinaryTypeTest {
+class BinaryTypeTest {
     @Test
-    public void binaryTypeTest() {
+    void binaryTypeTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/binary-type-test-models"));
         assertEquals(9, genTypes.size());
index 4c662f9294c0f0a83a94d905d0052eea126f0b85..59a4bb916ba906e237b71e9d3f3671d32ffcc4ef 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class BindingGeneratorImplTest {
+class BindingGeneratorImplTest {
     @Test
-    public void isisTotpologyStatementParserTest()  {
-        List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
+    void isisTotpologyStatementParserTest()  {
+        final var generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
             BindingGeneratorImplTest.class,
             "/isis-topology/network-topology@2013-10-21.yang", "/isis-topology/isis-topology@2013-10-21.yang",
             "/isis-topology/l3-unicast-igp-topology@2013-10-21.yang"));
@@ -29,8 +29,8 @@ public class BindingGeneratorImplTest {
     }
 
     @Test
-    public void choiceNodeGenerationTest() {
-        List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void choiceNodeGenerationTest() {
+        final var generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/binding-generator-impl-test/choice-test.yang"));
 
         GeneratedType choiceTestData = null;
@@ -40,28 +40,17 @@ public class BindingGeneratorImplTest {
         GeneratedType myList2 = null;
         GeneratedType myContainer2 = null;
 
-        for (GeneratedType type : generateTypes) {
+        for (var type : generateTypes) {
             switch (type.getName()) {
-                case "ChoiceTestData":
-                    choiceTestData = type;
-                    break;
-                case "Myrootcontainer":
-                    myRootContainer = type;
-                    break;
-                case "Mylist":
-                    myList = type;
-                    break;
-                case "Mylist2":
-                    myList2 = type;
-                    break;
-                case "Mycontainer":
-                    myContainer = type;
-                    break;
-                case "Mycontainer2":
-                    myContainer2 = type;
-                    break;
-                default:
+                case "ChoiceTestData" -> choiceTestData = type;
+                case "Myrootcontainer" -> myRootContainer = type;
+                case "Mylist" -> myList = type;
+                case "Mylist2" -> myList2 = type;
+                case "Mycontainer" -> myContainer = type;
+                case "Mycontainer2" -> myContainer2 = type;
+                default -> {
                     // ignore
+                }
             }
         }
 
@@ -73,9 +62,9 @@ public class BindingGeneratorImplTest {
         assertNotNull(myContainer2);
 
         Type childOfParamType = null;
-        for (Type type : myContainer.getImplements()) {
+        for (var type : myContainer.getImplements()) {
             if (type.getName().equals("ChildOf")) {
-                childOfParamType = ((ParameterizedType) type).getActualTypeArguments()[0];
+                childOfParamType = assertInstanceOf(ParameterizedType.class, type).getActualTypeArguments()[0];
                 break;
             }
         }
@@ -83,9 +72,9 @@ public class BindingGeneratorImplTest {
         assertEquals("ChoiceTestData", childOfParamType.getName());
 
         childOfParamType = null;
-        for (Type type : myList.getImplements()) {
+        for (var type : myList.getImplements()) {
             if (type.getName().equals("ChildOf")) {
-                childOfParamType = ((ParameterizedType) type).getActualTypeArguments()[0];
+                childOfParamType = assertInstanceOf(ParameterizedType.class, type).getActualTypeArguments()[0];
                 break;
             }
         }
@@ -93,9 +82,9 @@ public class BindingGeneratorImplTest {
         assertEquals("ChoiceTestData", childOfParamType.getName());
 
         childOfParamType = null;
-        for (Type type : myContainer2.getImplements()) {
+        for (var type : myContainer2.getImplements()) {
             if (type.getName().equals("ChildOf")) {
-                childOfParamType = ((ParameterizedType) type).getActualTypeArguments()[0];
+                childOfParamType = assertInstanceOf(ParameterizedType.class, type).getActualTypeArguments()[0];
                 break;
             }
         }
@@ -114,21 +103,23 @@ public class BindingGeneratorImplTest {
     }
 
     @Test
-    public void notificationGenerationTest() {
-        List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void notificationGenerationTest() {
+        final var generateTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/binding-generator-impl-test/notification-test.yang"));
 
         GeneratedType foo = null;
-        for (GeneratedType type : generateTypes) {
+        for (var type : generateTypes) {
             if (type.getName().equals("Foo")) {
                 foo = type;
                 break;
             }
         }
 
+        assertNotNull(foo);
+
         Type childOf = null;
         Type dataObject = null;
-        for (Type type :  foo.getImplements()) {
+        for (var type :  foo.getImplements()) {
             switch (type.getName()) {
                 case "ChildOf":
                     childOf = type;
@@ -146,7 +137,7 @@ public class BindingGeneratorImplTest {
     }
 
     @Test
-    public void testBaseYangTypes() {
+    void testBaseYangTypes() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/base-yang-types.yang"));
         assertEquals(19, types.size());
index 24731cbd25ad8aa199827d7d89a496458d2092e5..c40b7f0c09506a5ceddc1b8a585a6147e35c50c6 100644 (file)
@@ -7,32 +7,30 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsAttributes;
 import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsMethods;
 
 import java.util.List;
 import java.util.stream.Collectors;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class BitAndUnionTOEnclosingTest {
-
+class BitAndUnionTOEnclosingTest {
     private static List<GeneratedType> genTypes = null;
     private static GeneratedType parentContainer = null;
 
-    @BeforeClass
-    public static void loadTestResources() {
+    @BeforeAll
+    static void loadTestResources() {
         genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/bit_and_union.yang"));
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (genType.getName().equals("ParentContainer") && !(genType instanceof GeneratedTransferObject)) {
                 parentContainer = genType;
             }
@@ -40,159 +38,147 @@ public class BitAndUnionTOEnclosingTest {
     }
 
     @Test
-    public void testNestedTypesInLeaf() {
-        final List<GeneratedType> enclosedTypes = parentContainer.getEnclosedTypes();
+    void testNestedTypesInLeaf() {
+        final var enclosedTypes = parentContainer.getEnclosedTypes();
         assertEquals(3, enclosedTypes.size());
 
         // nested types in leaf
-        final List<GeneratedTransferObject> lfLeafs = enclosedTypes.stream()
+        final var lfLeafs = enclosedTypes.stream()
             .filter(genType -> genType.getName().equals("Lf"))
-            .map(genType -> {
-                assertThat(genType, instanceOf(GeneratedTransferObject.class));
-                return (GeneratedTransferObject) genType;
-            })
+            .map(genType -> assertInstanceOf(GeneratedTransferObject.class, genType))
             .collect(Collectors.toList());
-        assertEquals("Lf TO has incorrect number of occurences.", 1, lfLeafs.size());
-        GeneratedTransferObject lfLeaf = lfLeafs.get(0);
-        assertEquals("Lf has incorrect package name.",
-            "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
-            lfLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+        assertEquals(1, lfLeafs.size(), "Lf TO has incorrect number of occurences.");
+        final var lfLeaf = lfLeafs.getFirst();
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
+            lfLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+            "Lf has incorrect package name.");
 
-        assertEquals("Lf generated TO has incorrect number of properties", 2, lfLeaf.getProperties().size());
+        assertEquals(2, lfLeaf.getProperties().size(), "Lf generated TO has incorrect number of properties");
         containsAttributes(lfLeaf, true, true, true, new NameTypePattern("string", "String"));
         containsAttributes(lfLeaf, true, false, true, new NameTypePattern("lf$1", "Lf$1"));
 
         // nested types in Lf
-        final List<GeneratedType> lfTypes = lfLeaf.getEnclosedTypes();
+        final var lfTypes = lfLeaf.getEnclosedTypes();
         assertEquals(1, lfTypes.size());
 
-        final GeneratedType lf1Leaf = lfTypes.get(0);
+        final var lf1Leaf = lfTypes.getFirst();
         assertEquals("Lf$1", lf1Leaf.getName());
-        assertEquals("Lf$1 has incorrect package name.",
-            "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf",
-            lf1Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf",
+            lf1Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+            "Lf$1 has incorrect package name.");
 
-        assertThat(lf1Leaf, instanceOf(GeneratedTransferObject.class));
-        final GeneratedTransferObject lf1gto = (GeneratedTransferObject) lf1Leaf;
-        assertEquals("Lf$1 generated TO has incorrect number of properties", 4, lf1Leaf.getProperties().size());
+        final var lf1gto = assertInstanceOf(GeneratedTransferObject.class, lf1Leaf);
+        assertEquals(4, lf1Leaf.getProperties().size(), "Lf$1 generated TO has incorrect number of properties");
         containsAttributes(lf1gto, true, true, true, new NameTypePattern("uint32", "Uint32"));
         containsAttributes(lf1gto, true, true, true, new NameTypePattern("int8", "Byte"));
         containsAttributes(lf1gto, true, true, true, new NameTypePattern("string", "String"));
         containsAttributes(lf1gto, true, false, true, new NameTypePattern("lf$2", "Lf$2"));
 
         // nested types in Lf1
-        final List<GeneratedType> lf1Types = lf1Leaf.getEnclosedTypes();
+        final var lf1Types = lf1Leaf.getEnclosedTypes();
         assertEquals(1, lf1Types.size());
 
-        final GeneratedType lf2Leaf = lf1Types.get(0);
+        final var lf2Leaf = lf1Types.get(0);
         assertEquals("Lf$2", lf2Leaf.getName());
-        assertEquals("Lf$2 has incorrect package name.",
-            "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf.Lf$1",
-            lf2Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer.Lf.Lf$1",
+            lf2Leaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+            "Lf$2 has incorrect package name.");
 
 
-        assertThat(lf2Leaf, instanceOf(GeneratedTransferObject.class));
-        final GeneratedTransferObject lf2gto = (GeneratedTransferObject) lf2Leaf;
-        assertEquals("Lf generated TO has incorrect number of properties", 2, lf2Leaf.getProperties().size());
+        final var lf2gto = assertInstanceOf(GeneratedTransferObject.class, lf2Leaf);
+        assertEquals(2, lf2Leaf.getProperties().size(), "Lf generated TO has incorrect number of properties");
         containsAttributes(lf2gto, true, true, true, new NameTypePattern("string", "String"));
         containsAttributes(lf2gto, true, true, true, new NameTypePattern("uint64", "Uint64"));
     }
 
     @Test
-    public void testNestedTypesInTypedef() {
-
+    void testNestedTypesInTypedef() {
         GeneratedTransferObject typeUnionTypedef = null;
         int typeUnionTypedefCounter = 0;
 
-        for (GeneratedType genType : genTypes) {
-            if (genType.getName().equals("TypeUnion") && genType instanceof GeneratedTransferObject) {
-                typeUnionTypedef = (GeneratedTransferObject) genType;
+        for (var genType : genTypes) {
+            if (genType.getName().equals("TypeUnion") && genType instanceof GeneratedTransferObject gto) {
+                typeUnionTypedef = gto;
                 typeUnionTypedefCounter++;
             }
         }
 
-        assertNotNull("TypeUnion TO wasn't found.", typeUnionTypedef);
-        assertEquals("TypeUnion TO has incorrect number of occurences.", 1, typeUnionTypedefCounter);
+        assertNotNull(typeUnionTypedef, "TypeUnion TO wasn't found.");
+        assertEquals(1, typeUnionTypedefCounter, "TypeUnion TO has incorrect number of occurences.");
 
-        assertNotNull("TypeUnion TO wasn't found.", typeUnionTypedef);
-        assertEquals("TypeUnion TO has incorrect number of occurences.", 1, typeUnionTypedefCounter);
-        assertEquals("TypeUnion has incorrect package name.",
-                "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnionTypedef.getPackageName());
+        assertNotNull(typeUnionTypedef, "TypeUnion TO wasn't found.");
+        assertEquals(1, typeUnionTypedefCounter, "TypeUnion TO has incorrect number of occurences.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnionTypedef.getPackageName(),
+            "TypeUnion has incorrect package name.");
 
-        assertEquals("TypeUnion generated TO has incorrect number of properties", 2, typeUnionTypedef.getProperties()
-                .size());
+        assertEquals(2, typeUnionTypedef.getProperties().size(),
+            "TypeUnion generated TO has incorrect number of properties");
         containsAttributes(typeUnionTypedef, true, true, true, new NameTypePattern("string", "String"));
         containsAttributes(typeUnionTypedef, true, false, true, new NameTypePattern("typeUnion$1", "TypeUnion$1"));
 
-        List<GeneratedType> nestedUnions = typeUnionTypedef.getEnclosedTypes();
-        assertEquals("Incorrect number of nested unions", 1, nestedUnions.size());
+        final var nestedUnions = typeUnionTypedef.getEnclosedTypes();
+        assertEquals(1, nestedUnions.size(), "Incorrect number of nested unions");
 
-        GeneratedType typeUnion1 = nestedUnions.get(0);
+        final var typeUnion1 = nestedUnions.getFirst();
         assertEquals("TypeUnion$1", typeUnion1.getName());
-        assertEquals("TypeUnion$1 has incorrect package name.",
-            "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion1.getPackageName());
-        assertEquals("TypeUnion1 generated TO has incorrect number of properties", 4,
-            typeUnion1.getProperties().size());
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion1.getPackageName(),
+            "TypeUnion$1 has incorrect package name.");
+        assertEquals(4, typeUnion1.getProperties().size(),
+            "TypeUnion1 generated TO has incorrect number of properties");
 
-        assertThat(typeUnion1, instanceOf(GeneratedTransferObject.class));
-        GeneratedTransferObject typeUnion1gto = (GeneratedTransferObject) typeUnion1;
+        final var typeUnion1gto = assertInstanceOf(GeneratedTransferObject.class, typeUnion1);
         containsAttributes(typeUnion1gto, true, true, true, new NameTypePattern("uint32", "Uint32"));
         containsAttributes(typeUnion1gto, true, true, true, new NameTypePattern("int8", "Byte"));
         containsAttributes(typeUnion1gto, true, true, true, new NameTypePattern("string", "String"));
         containsAttributes(typeUnion1gto, true, false, true, new NameTypePattern("typeUnion$2", "TypeUnion$2"));
 
 
-        List<GeneratedType> nestedUnions1 = typeUnion1.getEnclosedTypes();
+        final var nestedUnions1 = typeUnion1.getEnclosedTypes();
         assertEquals(1, nestedUnions1.size());
 
-        GeneratedType typeUnion2 = nestedUnions1.get(0);
+        final var typeUnion2 = nestedUnions1.get(0);
         assertEquals("TypeUnion$2", typeUnion2.getName());
-        assertEquals("TypeUnion$2 has incorrect package name.",
-            "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion2.getPackageName());
-        assertEquals("TypeUnion2 generated TO has incorrect number of properties", 2,
-            typeUnion2.getProperties().size());
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion2.getPackageName(),
+            "TypeUnion$2 has incorrect package name.");
+        assertEquals(2, typeUnion2.getProperties().size(),
+            "TypeUnion2 generated TO has incorrect number of properties");
 
-        assertThat(typeUnion2, instanceOf(GeneratedTransferObject.class));
-        GeneratedTransferObject typeUnion2gto = (GeneratedTransferObject) typeUnion2;
+        final var typeUnion2gto = assertInstanceOf(GeneratedTransferObject.class, typeUnion2);
         containsAttributes(typeUnion2gto, true, true, true, new NameTypePattern("string", "String"));
         containsAttributes(typeUnion2gto, true, true, true, new NameTypePattern("uint64", "Uint64"));
     }
 
     @Test
     public void bitAndUnionEnclosingTest() {
-
-        assertNotNull("Parent container object wasn't found.", parentContainer);
+        assertNotNull(parentContainer, "Parent container object wasn't found.");
         containsMethods(parentContainer, new NameTypePattern("getLf", "Lf"));
 
         GeneratedTransferObject bitLeaf = null;
         GeneratedTransferObject unionLeaf = null;
-        List<GeneratedType> enclosedTypes = parentContainer.getEnclosedTypes();
-        for (GeneratedType genType : enclosedTypes) {
-            if (genType instanceof GeneratedTransferObject) {
-                if (genType.getName().equals("BitLeaf")) {
-                    bitLeaf = (GeneratedTransferObject) genType;
-                } else if (genType.getName().equals("UnionLeaf")) {
-                    unionLeaf = (GeneratedTransferObject) genType;
+        for (var genType : parentContainer.getEnclosedTypes()) {
+            if (genType instanceof GeneratedTransferObject gto) {
+                if (gto.getName().equals("BitLeaf")) {
+                    bitLeaf = gto;
+                } else if (gto.getName().equals("UnionLeaf")) {
+                    unionLeaf = gto;
                 }
             }
         }
 
-        assertNotNull("BitLeaf TO wasn't found.", bitLeaf);
-        assertNotNull("UnionLeaf TO wasn't found.", unionLeaf);
+        assertNotNull(bitLeaf, "BitLeaf TO wasn't found.");
+        assertNotNull(unionLeaf, "UnionLeaf TO wasn't found.");
 
-        assertEquals("BitLeaf has incorrect package name.",
-                "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
-                bitLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
-        assertEquals("UnionLeaf has incorrect package name.",
-                "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
-                unionLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
+            bitLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+            "BitLeaf has incorrect package name.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
+            unionLeaf.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString(),
+            "UnionLeaf has incorrect package name.");
 
-        List<GeneratedProperty> propertiesBitLeaf = bitLeaf.getProperties();
         GeneratedProperty firstBitProperty = null;
         GeneratedProperty secondBitProperty = null;
         GeneratedProperty thirdBitProperty = null;
-
-        for (GeneratedProperty genProperty : propertiesBitLeaf) {
+        for (var genProperty : bitLeaf.getProperties()) {
             if (genProperty.getName().equals("firstBit")) {
                 firstBitProperty = genProperty;
             } else if (genProperty.getName().equals("secondBit")) {
@@ -202,19 +188,17 @@ public class BitAndUnionTOEnclosingTest {
             }
         }
 
-        assertNotNull("firstBit property wasn't found", firstBitProperty);
-        assertNotNull("secondBit property wasn't found", secondBitProperty);
-        assertNotNull("thirdBit property wasn't found", thirdBitProperty);
-
-        assertEquals("firstBit property has incorrect type", "boolean", firstBitProperty.getReturnType().getName());
-        assertEquals("secondBit property has incorrect type", "boolean", secondBitProperty.getReturnType().getName());
-        assertEquals("thirdBit property has incorrect type", "boolean", thirdBitProperty.getReturnType().getName());
+        assertNotNull(firstBitProperty, "firstBit property wasn't found");
+        assertEquals("boolean", firstBitProperty.getReturnType().getName(), "firstBit property has incorrect type");
+        assertNotNull(secondBitProperty, "secondBit property wasn't found");
+        assertEquals("boolean", secondBitProperty.getReturnType().getName(), "secondBit property has incorrect type");
+        assertNotNull(thirdBitProperty, "thirdBit property wasn't found");
+        assertEquals("boolean", thirdBitProperty.getReturnType().getName(), "thirdBit property has incorrect type");
 
         GeneratedProperty uint32Property = null;
         GeneratedProperty stringProperty = null;
         GeneratedProperty uint8Property = null;
-        List<GeneratedProperty> propertiesUnionLeaf = unionLeaf.getProperties();
-        for (GeneratedProperty genProperty : propertiesUnionLeaf) {
+        for (var genProperty : unionLeaf.getProperties()) {
             if (genProperty.getName().equals("int32")) {
                 uint32Property = genProperty;
             } else if (genProperty.getName().equals("string")) {
@@ -224,14 +208,11 @@ public class BitAndUnionTOEnclosingTest {
             }
         }
 
-        assertNotNull("uint32 property wasn't found", uint32Property);
-        assertNotNull("string property wasn't found", stringProperty);
-        assertNotNull("uint8 property wasn't found", uint8Property);
-
-        assertEquals("uint32 property has incorrect type", "Integer", uint32Property.getReturnType().getName());
-        assertEquals("string property has incorrect type", "String", stringProperty.getReturnType().getName());
-        assertEquals("uint8 property has incorrect type", "Uint8", uint8Property.getReturnType().getName());
-
+        assertNotNull(uint32Property, "uint32 property wasn't found");
+        assertEquals("Integer", uint32Property.getReturnType().getName(), "uint32 property has incorrect type");
+        assertNotNull(stringProperty, "string property wasn't found");
+        assertEquals("String", stringProperty.getReturnType().getName(), "string property has incorrect type");
+        assertNotNull(uint8Property, "uint8 property wasn't found");
+        assertEquals("Uint8", uint8Property.getReturnType().getName(), "uint8 property has incorrect type");
     }
-
 }
index 1c20502ae90dbbc1f29009d1dab3cd85fd5aaa85..b7eedb62a1fe5b1722515ee7c525fb30c6969fd3 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class Bug4145Test {
+class Bug4145Test {
     @Test
-    public void bug4145Test() {
+    void bug4145Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/bug4145.yang"));
         assertEquals(8, generateTypes.size());
index f628511daf7d79ed1cf09b215934cfdf8aaefde7..cf312a7ebb7983e0cae0bc6e8d9870f90037cb4c 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Bug6135Test {
+class Bug6135Test {
     @Test
-    public void bug6135Test() {
+    void bug6135Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/bug6135.yang"));
         assertEquals(5, generateTypes.size());
index 5a87a67f8c02037b4000ea50b5be350cb0bd7114..6ff5991c5f427213da774de7c96507191a2bb187 100644 (file)
@@ -7,68 +7,79 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsInterface;
 import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsMethods;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class ChoiceCaseGenTypesTest {
+class ChoiceCaseGenTypesTest {
     @Test
-    public void choiceCaseResolvingTypeTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+    void choiceCaseResolvingTypeTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/choice-case-type-test-models"));
 
-        assertNotNull("genTypes is null", genTypes);
+        assertNotNull(genTypes, "genTypes is null");
         assertEquals(41, genTypes.size());
 
         // test for file choice-monitoring
-        String pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701."
+        var pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701."
                 + "netconf.state.datastores.datastore.locks";
         GeneratedType genType = null;
 
-        checkGeneratedType(genTypes, "LockType", pcgPref); // choice
+        // choice
+        checkGeneratedType(genTypes, "LockType", pcgPref);
 
-        genType = checkGeneratedType(genTypes, "GlobalLock", pcgPref + ".lock.type"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "GlobalLock", pcgPref + ".lock.type");
         SupportTestUtil.containsMethods(genType, new NameTypePattern("getGlobalLock", "GlobalLock"));
         containsInterface("LockType", genType);
 
-        genType = checkGeneratedType(genTypes, "PartialLock", pcgPref + ".lock.type"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "PartialLock", pcgPref + ".lock.type");
         containsMethods(genType, new NameTypePattern("getPartialLock", "Map<PartialLockKey,PartialLock>"));
         containsInterface("LockType", genType);
 
-        genType = checkGeneratedType(genTypes, "Fingerprint", pcgPref + ".lock.type"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Fingerprint", pcgPref + ".lock.type");
         containsMethods(genType, new NameTypePattern("getAlgorithmAndHash", "AlgorithmAndHash"));
         containsInterface("LockType", genType);
 
-        genType = checkGeneratedType(genTypes, "AlgorithmAndHash", pcgPref + ".lock.type.fingerprint"); // choice
+        // choice
+        genType = checkGeneratedType(genTypes, "AlgorithmAndHash", pcgPref + ".lock.type.fingerprint");
 
-        genType = checkGeneratedType(genTypes, "Md5", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Md5", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
         containsMethods(genType, new NameTypePattern("getMd5", "TlsFingerprintType"));
         containsInterface("AlgorithmAndHash", genType);
 
-        genType = checkGeneratedType(genTypes, "Sha1", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Sha1", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
         containsMethods(genType, new NameTypePattern("getSha1", "TlsFingerprintType"));
         containsInterface("AlgorithmAndHash", genType);
 
-        genType = checkGeneratedType(genTypes, "Sha224", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Sha224", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
         containsMethods(genType, new NameTypePattern("getSha224", "TlsFingerprintType"));
         containsInterface("AlgorithmAndHash", genType);
 
-        genType = checkGeneratedType(genTypes, "Sha256", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Sha256", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
         containsMethods(genType, new NameTypePattern("getSha256", "TlsFingerprintType"));
         containsInterface("AlgorithmAndHash", genType);
 
-        genType = checkGeneratedType(genTypes, "Sha384", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Sha384", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
         containsMethods(genType, new NameTypePattern("getSha384", "TlsFingerprintType"));
         containsInterface("AlgorithmAndHash", genType);
 
-        genType = checkGeneratedType(genTypes, "Sha512", pcgPref + ".lock.type.fingerprint.algorithm.and.hash"); // case
+        // case
+        genType = checkGeneratedType(genTypes, "Sha512", pcgPref + ".lock.type.fingerprint.algorithm.and.hash");
         containsMethods(genType, new NameTypePattern("getSha512", "TlsFingerprintType"));
         containsInterface("AlgorithmAndHash", genType);
 
@@ -77,38 +88,45 @@ public class ChoiceCaseGenTypesTest {
         // "/nm:netconf-state/nm:datastores/nm:datastore/nm:locks/nm:lock-type"
         pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.augment.monitoring.rev130701";
 
+        // choice
         genType = checkGeneratedType(genTypes, "AutonomousLock", pcgPref
-                + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
+                + ".netconf.state.datastores.datastore.locks.lock.type");
         containsMethods(genType, new NameTypePattern("getAutonomousDef", "AutonomousDef"));
         containsInterface("LockType", genType);
 
+        // choice
         genType = checkGeneratedType(genTypes, "AnonymousLock", pcgPref
-                + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
+                + ".netconf.state.datastores.datastore.locks.lock.type");
         containsMethods(genType, new NameTypePattern("getLockTime", "Uint32"));
         containsInterface("LockType", genType);
 
+        // choice
         genType = checkGeneratedType(genTypes, "LeafAugCase", pcgPref
-                + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
+                + ".netconf.state.datastores.datastore.locks.lock.type");
         containsMethods(genType, new NameTypePattern("getLeafAugCase", "String"));
         containsInterface("LockType", genType);
 
         // augment
         // "/nm:netconf-state/nm:datastores/nm:datastore/nm:locks/nm:lock-type/nm:partial-lock"
         // {
-        genType = checkGeneratedType(genTypes, "PartialLock1", pcgPref); // case
+        // case
+        genType = checkGeneratedType(genTypes, "PartialLock1", pcgPref);
         containsMethods(genType, new NameTypePattern("getAugCaseByChoice", "AugCaseByChoice"));
         containsInterface("Augmentation<PartialLock>", genType);
 
+        // choice
         genType = checkGeneratedType(genTypes, "AugCaseByChoice", pcgPref
-                + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock"); // choice
+                + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock");
 
+        // case
         genType = checkGeneratedType(genTypes, "Foo", pcgPref
-                + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice"); // case
+                + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice");
         containsMethods(genType, new NameTypePattern("getFoo", "String"));
         containsInterface("AugCaseByChoice", genType);
 
+        // case
         genType = checkGeneratedType(genTypes, "Bar", pcgPref
-                + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice"); // case
+                + ".netconf.state.datastores.datastore.locks.lock.type.partial.lock.aug._case.by.choice");
         containsMethods(genType, new NameTypePattern("getBar", "Boolean"));
         containsInterface("AugCaseByChoice", genType);
 
@@ -120,8 +138,9 @@ public class ChoiceCaseGenTypesTest {
         // choice
         genType = checkGeneratedType(genTypes, "StorageFormat", pcgPref + ".netconf.state.datastores.datastore");
 
+        // case
         genType = checkGeneratedType(genTypes, "UnknownFiles", pcgPref
-                + ".netconf.state.datastores.datastore.storage.format"); // case
+                + ".netconf.state.datastores.datastore.storage.format");
         containsMethods(genType, new NameTypePattern("getFiles", "Map<FilesKey,Files>"));
         containsInterface("StorageFormat", genType);
 
@@ -140,7 +159,7 @@ public class ChoiceCaseGenTypesTest {
             final String packageName, final int occurences) {
         GeneratedType searchedGenType = null;
         int searchedGenTypeCounter = 0;
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals(genTypeName) && genType.getPackageName().equals(packageName)) {
                     searchedGenType = genType;
@@ -148,9 +167,9 @@ public class ChoiceCaseGenTypesTest {
                 }
             }
         }
-        assertNotNull("Generated type " + genTypeName + " wasn't found", searchedGenType);
-        assertEquals(genTypeName + " generated type has incorrect number of occurences.", occurences,
-            searchedGenTypeCounter);
+        assertNotNull(searchedGenType, "Generated type " + genTypeName + " wasn't found");
+        assertEquals(occurences, searchedGenTypeCounter,
+            genTypeName + " generated type has incorrect number of occurences.");
         return searchedGenType;
 
     }
index 82d605f95f3b488090e5249d1734a5073946955e..922bf74f4a3d9954e5b00f4f5c5950d03043780c 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class ControllerTest {
+class ControllerTest {
     @Test
-    public void controllerAugmentationTest() {
+    void controllerAugmentationTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
             ControllerTest.class,
             "/controller-models/controller-network.yang", "/controller-models/controller-openflow.yang",
index 4ea7c8861bb3760cca821d19cf58e1078767c564..be241c0474750ec2c7450ce3e3417316499018c5 100644 (file)
@@ -7,20 +7,20 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+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 org.junit.Test;
+import java.util.List;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.ri.BaseYangTypes;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class ExtendedTypedefTest {
+class ExtendedTypedefTest {
     @Test
-    public void constantGenerationTest() {
+    void constantGenerationTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
             ExtendedTypedefTest.class, "/typedef_of_typedef.yang", "/ietf-models/ietf-inet-types.yang"));
 
@@ -28,75 +28,71 @@ public class ExtendedTypedefTest {
         GeneratedTransferObject extendedTypedefUnion = null;
         GeneratedTransferObject unionTypedef = null;
         GeneratedTransferObject typedefFromImport = null;
-        for (final GeneratedType type : genTypes) {
-            if (type instanceof GeneratedTransferObject) {
+        for (var type : genTypes) {
+            if (type instanceof GeneratedTransferObject gto) {
                 if (type.getName().equals("SimpleTypedef4")) {
-                    simpleTypedef4 = (GeneratedTransferObject) type;
+                    simpleTypedef4 = gto;
                 } else if (type.getName().equals("ExtendedTypedefUnion")) {
-                    extendedTypedefUnion = (GeneratedTransferObject) type;
+                    extendedTypedefUnion = gto;
                 } else if (type.getName().equals("UnionTypedef")) {
-                    unionTypedef = (GeneratedTransferObject) type;
+                    unionTypedef = gto;
                 } else if (type.getName().equals("TypedefFromImport")) {
-                    typedefFromImport = (GeneratedTransferObject) type;
+                    typedefFromImport = gto;
                 }
             }
         }
 
         // typedef-from-import
-        assertNotNull("TypedefFromImport not found", typedefFromImport);
-        var properties = typedefFromImport.getProperties();
-        assertEquals("Properties of TypedefFromImport should be empty", 0, properties.size());
-        assertEquals("TypedefFromImport should be extended", "Ipv4Address", typedefFromImport.getSuperType().getName());
+        assertNotNull(typedefFromImport, "TypedefFromImport not found");
+        assertEquals(List.of(), typedefFromImport.getProperties(), "Properties of TypedefFromImport should be empty");
+        assertEquals("Ipv4Address", typedefFromImport.getSuperType().getName(), "TypedefFromImport should be extended");
 
         // simple-typedef4
-        assertNotNull("SimpleTypedef4 not found", simpleTypedef4);
-        assertNotNull("ExtendedTypedefUnion not found", extendedTypedefUnion);
-        assertNotNull("UnionTypedef", unionTypedef);
+        assertNotNull(simpleTypedef4, "SimpleTypedef4 not found");
+        assertNotNull(extendedTypedefUnion, "ExtendedTypedefUnion not found");
+        assertNotNull(unionTypedef, "UnionTypedef");
 
-        properties = simpleTypedef4.getProperties();
-        assertEquals("SimpleTypedef4 shouldn't have properties.", 0, properties.size());
+        assertEquals(List.of(), simpleTypedef4.getProperties(), "SimpleTypedef4 shouldn't have properties.");
 
-        GeneratedTransferObject extendTO = simpleTypedef4.getSuperType();
-        assertNotNull("SimpleTypedef4 should have extend.", extendTO);
-        assertEquals("Incorrect extension for SimpleTypedef4.", "SimpleTypedef3", extendTO.getName());
-        properties = extendTO.getProperties();
-        assertEquals("SimpleTypedef3 shouldn't have properties.", 0, properties.size());
+        var extendTO = simpleTypedef4.getSuperType();
+        assertNotNull(extendTO, "SimpleTypedef4 should have extend.");
+        assertEquals("SimpleTypedef3", extendTO.getName(), "Incorrect extension for SimpleTypedef4.");
+        assertEquals(List.of(), extendTO.getProperties(), "SimpleTypedef3 shouldn't have properties.");
 
         extendTO = extendTO.getSuperType();
-        assertNotNull("SimpleTypedef3 should have extend.", extendTO);
-        assertEquals("Incorrect extension for SimpleTypedef3.", "SimpleTypedef2", extendTO.getName());
-        properties = extendTO.getProperties();
-        assertEquals("SimpleTypedef2 shouldn't have properties.", 0, properties.size());
+        assertNotNull(extendTO, "SimpleTypedef3 should have extend.");
+        assertEquals("SimpleTypedef2", extendTO.getName(), "Incorrect extension for SimpleTypedef3.");
+        assertEquals(List.of(), extendTO.getProperties(), "SimpleTypedef2 shouldn't have properties.");
 
         extendTO = extendTO.getSuperType();
-        assertNotNull("SimpleTypedef2 should have extend.", extendTO);
-        assertEquals("SimpleTypedef2 should be extended with SimpleTypedef1.", "SimpleTypedef1", extendTO.getName());
-        properties = extendTO.getProperties();
-        assertEquals("Incorrect number of properties in class SimpleTypedef1.", 1, properties.size());
+        assertNotNull(extendTO, "SimpleTypedef2 should have extend.");
+        assertEquals("SimpleTypedef1", extendTO.getName(), "SimpleTypedef2 should be extended with SimpleTypedef1.");
+        var properties = extendTO.getProperties();
+        assertEquals(1, properties.size(), "Incorrect number of properties in class SimpleTypedef1.");
 
-        assertEquals("Incorrect property's name", "value", properties.get(0).getName());
-        assertEquals("Property's incorrect type", BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType());
+        assertEquals("value", properties.getFirst().getName(), "Incorrect property's name");
+        assertEquals(BaseYangTypes.UINT8_TYPE, properties.get(0).getReturnType(), "Property's incorrect type");
 
         extendTO = extendTO.getSuperType();
-        assertNull("SimpleTypedef1 shouldn't have extend.", extendTO);
+        assertNull(extendTO, "SimpleTypedef1 shouldn't have extend.");
 
         // extended-typedef-union
-        assertNotNull("ExtendedTypedefUnion object not found", extendedTypedefUnion);
-        properties = extendedTypedefUnion.getProperties();
-        assertEquals("ExtendedTypedefUnion shouldn't have any property", 0, properties.size());
+        assertNotNull(extendedTypedefUnion, "ExtendedTypedefUnion object not found");
+        assertEquals(List.of(), extendedTypedefUnion.getProperties(),
+            "ExtendedTypedefUnion shouldn't have any property");
 
         extendTO = extendedTypedefUnion.getSuperType();
-        assertEquals("Incorrect extension fo ExtendedTypedefUnion.", "UnionTypedef", extendTO.getName());
-        assertNull("UnionTypedef shouldn't be extended", extendTO.getSuperType());
+        assertEquals("UnionTypedef", extendTO.getName(), "Incorrect extension fo ExtendedTypedefUnion.");
+        assertNull(extendTO.getSuperType(), "UnionTypedef shouldn't be extended");
 
         properties = extendTO.getProperties();
-        assertEquals("Incorrect number of properties for UnionTypedef.", 4, properties.size());
+        assertEquals(4, properties.size(), "Incorrect number of properties for UnionTypedef.");
 
         GeneratedProperty simpleTypedef4Property = null;
         GeneratedProperty simpleTypedef1Property = null;
         GeneratedProperty byteTypeProperty = null;
         GeneratedProperty typedefEnumFruitProperty = null;
-        for (GeneratedProperty genProperty : properties) {
+        for (var genProperty : properties) {
             if (genProperty.getName().equals("simpleTypedef1")) {
                 simpleTypedef1Property = genProperty;
             } else if (genProperty.getName().equals("simpleTypedef4")) {
@@ -108,17 +104,17 @@ public class ExtendedTypedefTest {
             }
         }
 
-        assertNotNull("simpleTypedef4 property not found in UnionTypedef", simpleTypedef4Property);
-        assertNotNull("simpleTypedef1 property not found in UnionTypedef", simpleTypedef1Property);
-        assertNotNull("byteType property not found in UnionTypedef", byteTypeProperty);
-        assertNotNull("typedefEnumFruit property not found in UnionTypedef", typedefEnumFruitProperty);
-
-        assertEquals("Incorrect type for property simpleTypedef4.", "SimpleTypedef4", simpleTypedef4Property
-                .getReturnType().getName());
-        assertEquals("Incorrect type for property simpleTypedef1.", "SimpleTypedef1", simpleTypedef1Property
-                .getReturnType().getName());
-        assertEquals("Incorrect type for property byteType.", "ByteType", byteTypeProperty.getReturnType().getName());
-        assertEquals("Incorrect type for property typedefEnumFruit.", "TypedefEnumFruit", typedefEnumFruitProperty
-                .getReturnType().getName());
+        assertNotNull(simpleTypedef4Property, "simpleTypedef4 property not found in UnionTypedef");
+        assertNotNull(simpleTypedef1Property, "simpleTypedef1 property not found in UnionTypedef");
+        assertNotNull(byteTypeProperty, "byteType property not found in UnionTypedef");
+        assertNotNull(typedefEnumFruitProperty, "typedefEnumFruit property not found in UnionTypedef");
+
+        assertEquals("SimpleTypedef4", simpleTypedef4Property.getReturnType().getName(),
+            "Incorrect type for property simpleTypedef4.");
+        assertEquals("SimpleTypedef1", simpleTypedef1Property.getReturnType().getName(),
+            "Incorrect type for property simpleTypedef1.");
+        assertEquals("ByteType", byteTypeProperty.getReturnType().getName(), "Incorrect type for property byteType.");
+        assertEquals("TypedefEnumFruit", typedefEnumFruitProperty.getReturnType().getName(),
+            "Incorrect type for property typedefEnumFruit.");
     }
 }
index 38f6a70ffcd8e10c87140d3fe91f1c8340663f43..4787844c9db4d49da8c3e8109c2526fb3b53f719 100644 (file)
@@ -7,20 +7,18 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.Enumeration;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GenEnumResolvingTest {
+class GenEnumResolvingTest {
     @Test
-    public void testLeafEnumResolving() {
+    void testLeafEnumResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
             GenEnumResolvingTest.class,
             "/enum-test-models/ietf-interfaces@2012-11-15.yang", "/ietf-models/iana-if-type.yang"));
@@ -34,14 +32,14 @@ public class GenEnumResolvingTest {
                 genInterface = type;
             }
         }
-        assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
+        assertNotNull(genInterface, "Generated Type Interface is not present in list of Generated Types");
 
         Enumeration linkUpDownTrapEnable = null;
         Enumeration operStatus = null;
         final var enums = genInterface.getEnumerations();
-        assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", enums);
-        assertEquals("Generated Type Interface MUST contain 2 Enumeration Types", 2, enums.size());
-        for (final Enumeration e : enums) {
+        assertNotNull(enums, "Generated Type Interface cannot contain NULL reference to Enumeration types!");
+        assertEquals(2, enums.size(), "Generated Type Interface MUST contain 2 Enumeration Types");
+        for (var e : enums) {
             if (e.getName().equals("LinkUpDownTrapEnable")) {
                 linkUpDownTrapEnable = e;
             } else if (e.getName().equals("OperStatus")) {
@@ -49,18 +47,18 @@ public class GenEnumResolvingTest {
             }
         }
 
-        assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
-        assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
+        assertNotNull(linkUpDownTrapEnable, "Expected Enum LinkUpDownTrapEnable, but was NULL!");
+        assertNotNull(operStatus, "Expected Enum OperStatus, but was NULL!");
 
-        assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!",
-                linkUpDownTrapEnable.getValues());
-        assertNotNull("Enum OperStatus MUST contain Values definition not NULL reference!", operStatus.getValues());
-        assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2, linkUpDownTrapEnable.getValues().size());
-        assertEquals("Enum OperStatus MUST contain 7 values!", 7, operStatus.getValues().size());
+        assertNotNull(linkUpDownTrapEnable.getValues(),
+            "Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!");
+        assertNotNull(operStatus.getValues(), "Enum OperStatus MUST contain Values definition not NULL reference!");
+        assertEquals(2, linkUpDownTrapEnable.getValues().size(), "Enum LinkUpDownTrapEnable MUST contain 2 values!");
+        assertEquals(7, operStatus.getValues().size(), "Enum OperStatus MUST contain 7 values!");
 
         final var methods = genInterface.getMethodDefinitions();
 
-        assertNotNull("Generated Interface cannot contain NULL reference for Method Signature Definitions!", methods);
+        assertNotNull(methods, "Generated Interface cannot contain NULL reference for Method Signature Definitions!");
 
         // FIXME: split this into getter/default/static asserts
         assertEquals(33, methods.size());
@@ -73,26 +71,23 @@ public class GenEnumResolvingTest {
             }
         }
 
-        assertNotNull("Method getType MUST return Enumeration Type not NULL reference!", ianaIfType);
-        assertEquals("Enumeration getType MUST contain 272 values!", 272, ianaIfType.getValues().size());
+        assertNotNull(ianaIfType, "Method getType MUST return Enumeration Type not NULL reference!");
+        assertEquals(272, ianaIfType.getValues().size(), "Enumeration getType MUST contain 272 values!");
     }
 
     @Test
-    public void testTypedefEnumResolving() {
+    void testTypedefEnumResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/ietf-models/iana-if-type.yang"));
         assertNotNull(genTypes);
         assertEquals(2, genTypes.size());
 
-        final var type = genTypes.get(1);
-        assertThat(type, instanceOf(Enumeration.class));
-
-        final var enumer = (Enumeration) type;
-        assertEquals("Enumeration type MUST contain 272 values!", 272, enumer.getValues().size());
+        final var type = assertInstanceOf(Enumeration.class, genTypes.get(1));
+        assertEquals(272, type.getValues().size(), "Enumeration type MUST contain 272 values!");
     }
 
     @Test
-    public void testLeafrefEnumResolving() {
+    void testLeafrefEnumResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
             GenEnumResolvingTest.class,
             "/enum-test-models/abstract-topology@2013-02-08.yang", "/enum-test-models/ietf-interfaces@2012-11-15.yang",
@@ -107,31 +102,29 @@ public class GenEnumResolvingTest {
                 genInterface = type;
             }
         }
-        assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
+        assertNotNull(genInterface, "Generated Type Interface is not present in list of Generated Types");
 
-        Type linkUpDownTrapEnable = null;
-        Type operStatus = null;
+        Enumeration linkUpDownTrapEnable = null;
+        Enumeration operStatus = null;
         final var methods = genInterface.getMethodDefinitions();
-        assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", methods);
+        assertNotNull(methods, "Generated Type Interface cannot contain NULL reference to Enumeration types!");
 
         // FIXME: split this into getter/default/static asserts
         assertEquals(13, methods.size());
         for (var method : methods) {
             if (method.getName().equals("getLinkUpDownTrapEnable")) {
-                linkUpDownTrapEnable = method.getReturnType();
+                linkUpDownTrapEnable = assertInstanceOf(Enumeration.class, method.getReturnType());
             } else if (method.getName().equals("getOperStatus")) {
-                operStatus = method.getReturnType();
+                operStatus = assertInstanceOf(Enumeration.class, method.getReturnType());
             }
         }
 
-        assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
-        assertThat(linkUpDownTrapEnable, instanceOf(Enumeration.class));
+        assertNotNull(linkUpDownTrapEnable, "Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!");
         assertEquals(
             "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface",
             linkUpDownTrapEnable.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
 
-        assertNotNull("Expected Referenced Enum OperStatus, but was NULL!", operStatus);
-        assertThat(operStatus, instanceOf(Enumeration.class));
+        assertNotNull(operStatus, "Expected Referenced Enum OperStatus, but was NULL!");
         assertEquals(
             "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface",
             operStatus.getIdentifier().immediatelyEnclosingClass().orElseThrow().toString());
index c8e6c5b1b2b6937e7a2acdd6d23062c4361710bf..88b6720416449921071764729a7dababc180e10e 100644 (file)
@@ -7,17 +7,17 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.util.HashSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GenTypesSubSetTest {
+class GenTypesSubSetTest {
     @Test
-    public void genTypesFromSubsetOfTwoModulesTest() {
+    void genTypesFromSubsetOfTwoModulesTest() {
         final var context = YangParserTestUtils.parseYangResources(GenTypesSubSetTest.class,
                 "/leafref-test-models/abstract-topology@2013-02-08.yang", "/ietf-models/ietf-interfaces.yang",
                 "/ietf-models/ietf-inet-types.yang", "/ietf-models/ietf-yang-types.yang");
@@ -28,14 +28,14 @@ public class GenTypesSubSetTest {
             }
         }
 
-        assertEquals("Set of to Generate Modules must contain 2 modules", 2, toGenModules.size());
+        assertEquals(2, toGenModules.size(), "Set of to Generate Modules must contain 2 modules");
         final var genTypes = DefaultBindingGenerator.generateFor(context, toGenModules);
-        assertNotNull("genTypes is null", genTypes);
+        assertNotNull(genTypes, "genTypes is null");
         assertEquals(25, genTypes.size());
     }
 
     @Test
-    public void genTypesFromSubsetOfThreeModulesTest() {
+    void genTypesFromSubsetOfThreeModulesTest() {
         final var context = YangParserTestUtils.parseYangResources(GenTypesSubSetTest.class,
                 "/leafref-test-models/abstract-topology@2013-02-08.yang", "/ietf-models/ietf-interfaces.yang",
                 "/ietf-models/ietf-inet-types.yang", "/ietf-models/ietf-yang-types.yang",
@@ -49,10 +49,10 @@ public class GenTypesSubSetTest {
                 toGenModules.add(module);
             }
         }
-        assertEquals("Set of to Generate Modules must contain 3 modules", 3, toGenModules.size());
+        assertEquals(3, toGenModules.size(), "Set of to Generate Modules must contain 3 modules");
 
         final var genTypes = DefaultBindingGenerator.generateFor(context, toGenModules);
-        assertNotNull("genTypes is null", genTypes);
+        assertNotNull(genTypes, "genTypes is null");
         assertEquals(27, genTypes.size());
     }
 }
index b5166b77a42cc2ced9eb3d7be462f6547bd87b76..004c95c68d59118acb488acf73020561e3e979d0 100644 (file)
@@ -7,22 +7,20 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.ri.BaseYangTypes;
 import org.opendaylight.yangtools.binding.model.ri.Types;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GenerateInnerClassForBitsAndUnionInLeavesTest {
+class GenerateInnerClassForBitsAndUnionInLeavesTest {
     @Test
-    public void testInnerClassCreationForBitsAndUnionsInLeafes() {
+    void testInnerClassCreationForBitsAndUnionsInLeafes() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/bit_and_union_in_leaf.yang"));
         assertEquals(4, genTypes.size());
@@ -36,14 +34,13 @@ public class GenerateInnerClassForBitsAndUnionInLeavesTest {
                 if (type.getName().equals("ParentContainer")) {
                     parentContainerFound = true;
                     GeneratedType parentContainer = type;
-                    List<GeneratedType> enclosedTypes = parentContainer.getEnclosedTypes();
-                    for (var genType : enclosedTypes) {
+                    for (var genType : parentContainer.getEnclosedTypes()) {
                         if (genType instanceof GeneratedTransferObject gto) {
                             if (genType.getName().equals("BitLeaf")) {
-                                assertFalse("Unexpected duplicate BitLeaf", bitLeafTOFound);
+                                assertFalse(bitLeafTOFound, "Unexpected duplicate BitLeaf");
                                 bitLeafTOFound = true;
 
-                                List<GeneratedProperty> bitLeafProperties = gto.getProperties();
+                                final var bitLeafProperties = gto.getProperties();
                                 assertEquals(3, bitLeafProperties.size());
 
                                 boolean firstBitPropertyFound = false;
@@ -65,10 +62,10 @@ public class GenerateInnerClassForBitsAndUnionInLeavesTest {
                                 assertTrue(secondBitPropertyFound);
                                 assertTrue(thirdBitPropertyFound);
                             } else if (genType.getName().equals("UnionLeaf")) {
-                                assertFalse("Unexpected duplicate UnionLeaf", unionLeafTOFound);
+                                assertFalse(unionLeafTOFound, "Unexpected duplicate UnionLeaf");
                                 unionLeafTOFound = true;
 
-                                List<GeneratedProperty> unionLeafProperties = gto.getProperties();
+                                final var unionLeafProperties = gto.getProperties();
                                 assertEquals(3, unionLeafProperties.size());
 
                                 boolean int32UnionPropertyFound = false;
index 70029e8e9d446c437316b45afeca8a0531080f50..f49a8c6762c0f6d0ce055161943c08fea64bc0ae 100644 (file)
@@ -7,25 +7,24 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.binding.model.api.MethodSignature.Parameter;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GeneratedTypesBitsTest {
+class GeneratedTypesBitsTest {
     @Test
-    public void testGeneretedTypesBitsTest() {
+    void testGeneretedTypesBitsTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/simple-bits-demo.yang"));
-        assertTrue(genTypes != null);
+        assertNotNull(genTypes);
 
         List<MethodSignature> methodSignaturesList = null;
 
@@ -46,7 +45,7 @@ public class GeneratedTypesBitsTest {
             if (genType instanceof GeneratedTransferObject genTO) {
                 if (genTO.getName().equals("ByteType")) {
                     byteTypeFound = true;
-                    List<GeneratedProperty> genProperties = genTO.getProperties();
+                    var genProperties = genTO.getProperties();
                     classPropertiesNumb = genProperties.size();
 
                     genProperties = genTO.getToStringIdentifiers();
index 6069d7920c23db1a9a0675da48e9292bc90be2c8..3b69b6541d00b147e8683764ea283666dbd15109 100644 (file)
@@ -7,15 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertThrows;
-
-import org.junit.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.contract.Naming;
 import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
@@ -24,9 +23,9 @@ import org.opendaylight.yangtools.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GeneratedTypesLeafrefTest {
+class GeneratedTypesLeafrefTest {
     @Test
-    public void testLeafrefResolving() {
+    void testLeafrefResolving() {
         final var context = YangParserTestUtils.parseYangResources(GeneratedTypesLeafrefTest.class,
             "/leafref-test-models/abstract-topology@2013-02-08.yang", "/ietf-models/ietf-interfaces.yang",
             "/ietf-models/ietf-inet-types.yang", "/ietf-models/ietf-yang-types.yang");
@@ -49,20 +48,33 @@ public class GeneratedTypesLeafrefTest {
                     && "org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces".equals(
                         type.getPackageName())) {
                 gtIfcKey = (GeneratedTransferObject) type;
-            } else if ("Interface".equals(name)) {
-                gtIfc = (GeneratedType) type;
-            } else if ("NetworkLink".equals(name)) {
-                gtNetworkLink = (GeneratedType) type;
-            } else if ("SourceNode".equals(name)) {
-                gtSource = (GeneratedType) type;
-            } else if ("DestinationNode".equals(name)) {
-                gtDest = (GeneratedType) type;
-            } else if ("Tunnel".equals(name)) {
-                gtTunnel = (GeneratedType) type;
-            } else if ("TunnelKey".equals(name)) {
-                gtTunnelKey = (GeneratedTransferObject) type;
-            } else if ("Topology".equals(name)) {
-                gtTopology = (GeneratedType) type;
+            } else {
+                switch (name) {
+                    case "Interface":
+                        gtIfc = (GeneratedType) type;
+                        break;
+                    case "NetworkLink":
+                        gtNetworkLink = (GeneratedType) type;
+                        break;
+                    case "SourceNode":
+                        gtSource = (GeneratedType) type;
+                        break;
+                    case "DestinationNode":
+                        gtDest = (GeneratedType) type;
+                        break;
+                    case "Tunnel":
+                        gtTunnel = (GeneratedType) type;
+                        break;
+                    case "TunnelKey":
+                        gtTunnelKey = (GeneratedTransferObject) type;
+                        break;
+                    case "Topology":
+                        gtTopology = (GeneratedType) type;
+                        break;
+                    case null:
+                    default:
+                        break;
+                }
             }
         }
 
@@ -121,13 +133,13 @@ public class GeneratedTypesLeafrefTest {
             }
         }
         assertNotNull(getIfcKey);
-        Type getIfcKeyType = getIfcKey.getReturnType();
+        final var getIfcKeyType = getIfcKey.getReturnType();
         assertNotNull(getIfcKeyType);
         assertNotSame("java.lang.Void", getIfcKeyType);
         assertEquals("InterfaceKey", getIfcKeyType.getName());
 
         assertNotNull(getHigherLayerIf);
-        Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
+        final var getHigherLayerIfType = getHigherLayerIf.getReturnType();
         assertNotNull(getHigherLayerIfType);
         assertNotSame("java.lang.Void", getHigherLayerIfType);
         assertEquals("Set", getHigherLayerIfType.getName());
@@ -136,13 +148,13 @@ public class GeneratedTypesLeafrefTest {
         final var gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();
         assertNotNull(gtNetworkLinkMethods);
         MethodSignature getIfc = null;
-        for (MethodSignature method : gtNetworkLinkMethods) {
+        for (var method : gtNetworkLinkMethods) {
             if (method.getName().equals("getInterface")) {
                 getIfc = method;
             }
         }
         assertNotNull(getIfc);
-        Type getIfcType = getIfc.getReturnType();
+        final var getIfcType = getIfc.getReturnType();
         assertNotNull(getIfcType);
         assertNotSame("java.lang.Void", getIfcType);
         assertEquals("String", getIfcType.getName());
@@ -157,7 +169,7 @@ public class GeneratedTypesLeafrefTest {
             }
         }
         assertNotNull(getIdSource);
-        Type getIdType = getIdSource.getReturnType();
+        final var getIdType = getIdSource.getReturnType();
         assertNotNull(getIdType);
         assertNotSame("java.lang.Void", getIdType);
         assertEquals("Uri", getIdType.getName());
@@ -172,7 +184,7 @@ public class GeneratedTypesLeafrefTest {
             }
         }
         assertNotNull(getIdDest);
-        Type getIdDestType = getIdDest.getReturnType();
+        final var getIdDestType = getIdDest.getReturnType();
         assertNotNull(getIdDestType);
         assertNotSame("java.lang.Void", getIdDestType);
         assertEquals("Uri", getIdDestType.getName());
@@ -187,7 +199,7 @@ public class GeneratedTypesLeafrefTest {
             }
         }
         assertNotNull(getTunnelKey);
-        Type getTunnelKeyType = getTunnelKey.getReturnType();
+        final var getTunnelKeyType = getTunnelKey.getReturnType();
         assertNotNull(getTunnelKeyType);
         assertNotSame("java.lang.Void", getTunnelKeyType);
         assertEquals("TunnelKey", getTunnelKeyType.getName());
@@ -202,7 +214,7 @@ public class GeneratedTypesLeafrefTest {
             }
         }
         assertNotNull(tunnelId);
-        Type tunnelIdType = tunnelId.getReturnType();
+        final var tunnelIdType = tunnelId.getReturnType();
         assertNotNull(tunnelIdType);
         assertNotSame("java.lang.Void", tunnelIdType);
         assertEquals("Uri", tunnelIdType.getName());
@@ -216,8 +228,7 @@ public class GeneratedTypesLeafrefTest {
         final var uoe = assertThrows(UnsupportedOperationException.class,
             () -> DefaultBindingGenerator.generateFor(context));
         assertEquals("Cannot ascertain type", uoe.getMessage());
-        final var cause = uoe.getCause();
-        assertThat(cause, instanceOf(IllegalArgumentException.class));
-        assertThat(cause.getMessage(), containsString("Failed to find leafref target"));
+        final var cause = assertInstanceOf(IllegalArgumentException.class, uoe.getCause());
+        assertThat(cause.getMessage()).contains("Failed to find leafref target");
     }
 }
index f8f2b12e41ce6b4e25f6c5065ca26f27e3c7bc2f..0b305b0a6100d808c85e04f7883dc6e62a728770 100644 (file)
@@ -7,20 +7,19 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.List;
 import java.util.Map;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.Constant;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GeneratedTypesStringTest {
+class GeneratedTypesStringTest {
     @Test
-    public void constantGenerationTest() {
+    void constantGenerationTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/simple-string-demo.yang"));
 
@@ -36,16 +35,15 @@ public class GeneratedTypesStringTest {
                 if (genTO.getName().equals("TypedefString")) {
                     typedefStringFound = true;
 
-                    List<Constant> constants = genTO.getConstantDefinitions();
-                    for (Constant con : constants) {
+                    for (var con : genTO.getConstantDefinitions()) {
                         if (con.getName().equals("PATTERN_CONSTANTS")) {
                             constantRegExListFound = true;
                         } else {
                             break;
                         }
                         ParameterizedType paramType;
-                        if (con.getType() instanceof ParameterizedType) {
-                            paramType = (ParameterizedType) con.getType();
+                        if (con.getType() instanceof ParameterizedType parameterized) {
+                            paramType = parameterized;
                         } else {
                             break;
                         }
@@ -89,12 +87,12 @@ public class GeneratedTypesStringTest {
 
         }
 
-        assertTrue("Typedef >>TypedefString<< wasn't found", typedefStringFound);
-        assertTrue("Constant PATTERN_CONSTANTS is missing in TO", constantRegExListFound);
-        assertTrue("Constant PATTERN_CONSTANTS doesn't have correct container type", constantRegExListTypeContainer);
-        assertTrue("Constant PATTERN_CONSTANTS has more than one generic type", constantRegExListTypeOneGeneric);
-        assertTrue("Constant PATTERN_CONSTANTS doesn't have correct generic type", constantRegExListTypeGeneric);
-        assertTrue("Constant PATTERN_CONSTANTS doesn't contain List object", constantRegExListValueOK);
-        assertTrue("In list found other type than String", !noStringInReqExListFound);
+        assertTrue(typedefStringFound, "Typedef >>TypedefString<< wasn't found");
+        assertTrue(constantRegExListFound, "Constant PATTERN_CONSTANTS is missing in TO");
+        assertTrue(constantRegExListTypeContainer, "Constant PATTERN_CONSTANTS doesn't have correct container type");
+        assertTrue(constantRegExListTypeOneGeneric, "Constant PATTERN_CONSTANTS has more than one generic type");
+        assertTrue(constantRegExListTypeGeneric, "Constant PATTERN_CONSTANTS doesn't have correct generic type");
+        assertTrue(constantRegExListValueOK, "Constant PATTERN_CONSTANTS doesn't contain List object");
+        assertFalse(noStringInReqExListFound, "In list found other type than String");
     }
 }
index dbf2b09b259f3d132bab550901522f4ef821d33d..bd13a3c9b8034c4bd699c78ec75237bda7d6c669 100644 (file)
@@ -7,18 +7,18 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.contract.Naming;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class GeneratedTypesTest {
+class GeneratedTypesTest {
     @Test
-    public void testMultipleModulesResolving() {
+    void testMultipleModulesResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResources(GeneratedTypesTest.class,
                 "/abstract-topology.yang", "/ietf-models/ietf-inet-types.yang"));
@@ -26,7 +26,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testContainerResolving() {
+    void testContainerResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/simple-container-demo.yang"));
 
@@ -108,7 +108,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testLeafListResolving() {
+    void testLeafListResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/simple-leaf-list-demo.yang"));
 
@@ -193,7 +193,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testListResolving() {
+    void testListResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/simple-list-demo.yang"));
 
@@ -258,19 +258,19 @@ public class GeneratedTypesTest {
                 final var hashProps = genTO.getHashCodeIdentifiers();
                 final var equalProps = genTO.getEqualsIdentifiers();
 
-                assertEquals("Unexpected key", 0, listKeyClassCount++);
+                assertEquals(0, listKeyClassCount++, "Unexpected key");
                 assertEquals(1, properties.size());
-                assertEquals("listKey", properties.get(0).getName());
-                assertEquals("Byte", properties.get(0).getReturnType().getName());
-                assertTrue(properties.get(0).isReadOnly());
+                assertEquals("listKey", properties.getFirst().getName());
+                assertEquals("Byte", properties.getFirst().getReturnType().getName());
+                assertTrue(properties.getFirst().isReadOnly());
 
                 assertEquals(1, hashProps.size());
-                assertEquals("listKey", hashProps.get(0).getName());
-                assertEquals("Byte", hashProps.get(0).getReturnType().getName());
+                assertEquals("listKey", hashProps.getFirst().getName());
+                assertEquals("Byte", hashProps.getFirst().getReturnType().getName());
 
                 assertEquals(1, equalProps.size());
-                assertEquals("listKey", equalProps.get(0).getName());
-                assertEquals("Byte",  equalProps.get(0).getReturnType().getName());
+                assertEquals("listKey", equalProps.getFirst().getName());
+                assertEquals("Byte",  equalProps.getFirst().getReturnType().getName());
             }
         }
 
@@ -296,7 +296,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testListCompositeKeyResolving() {
+    void testListCompositeKeyResolving() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/list-composite-key.yang"));
 
@@ -336,7 +336,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testGeneratedTypes() {
+    void testGeneratedTypes() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/demo-topology.yang"));
 
@@ -358,7 +358,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testAugmentRpcInput() {
+    void testAugmentRpcInput() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
             "/augment-rpc-input.yang"));
         assertEquals(6, genTypes.size());
index 06f6e2892198034072fbaa3cae5f9b157600f42f..0ff4e65cf457cc9b3f01cf6fd74c28af7783a054 100644 (file)
@@ -7,22 +7,21 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.File;
-import java.net.URISyntaxException;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class IdentityrefTypeTest {
-    private static List<File> testModels;
+class IdentityrefTypeTest {
+    private List<File> testModels;
 
-    @Before
-    public void loadTestResources() throws URISyntaxException {
+    @BeforeEach
+    void loadTestResources() throws Exception {
         final var folderFile = Path.of(IdentityrefTypeTest.class.getResource("/identityref.yang").toURI()).toFile();
         testModels = new ArrayList<>();
 
@@ -42,7 +41,7 @@ public class IdentityrefTypeTest {
      * provideTypeForIdentityref}.
      */
     @Test
-    public void testIdentityrefYangBuiltInType() {
+    void testIdentityrefYangBuiltInType() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangFiles(testModels));
         assertEquals(2, genTypes.size());
 
index 0e741eccc5b167634a082b413323c1057a2023b5..16db32ce93960c79187938e15bb7d1685acc8160 100644 (file)
@@ -7,23 +7,18 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.assertThrows;
 
-import java.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.binding.model.api.MethodSignature;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.ri.Types;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class LeafrefResolutionTest {
+class LeafrefResolutionTest {
     @Test
-    public void testLeafRefRelativeSelfReference() {
-        final EffectiveModelContext schemaContext =
-            YangParserTestUtils.parseYangResource("/leafref-relative-invalid.yang");
-        final IllegalArgumentException iae = assertThrows(IllegalArgumentException.class,
+    void testLeafRefRelativeSelfReference() {
+        final var schemaContext = YangParserTestUtils.parseYangResource("/leafref-relative-invalid.yang");
+        final var iae = assertThrows(IllegalArgumentException.class,
             () -> DefaultBindingGenerator.generateFor(schemaContext));
         assertEquals(
             "Effective model contains self-referencing leaf (urn:xml:ns:yang:lrr?revision=2015-02-25)neighbor-id",
@@ -31,10 +26,9 @@ public class LeafrefResolutionTest {
     }
 
     @Test
-    public void testLeafRefAbsoluteSelfReference() {
-        final EffectiveModelContext schemaContext =
-            YangParserTestUtils.parseYangResource("/leafref-absolute-invalid.yang");
-        final IllegalArgumentException iae = assertThrows(IllegalArgumentException.class,
+    void testLeafRefAbsoluteSelfReference() {
+        final var schemaContext = YangParserTestUtils.parseYangResource("/leafref-absolute-invalid.yang");
+        final var iae = assertThrows(IllegalArgumentException.class,
             () -> DefaultBindingGenerator.generateFor(schemaContext));
         assertEquals(
             "Effective model contains self-referencing leaf (urn:xml:ns:yang:lra?revision=2015-02-25)neighbor-id",
@@ -42,25 +36,25 @@ public class LeafrefResolutionTest {
     }
 
     @Test
-    public void testLeafRefRelativeAndAbsoluteValidReference() {
-        final List<GeneratedType> types = DefaultBindingGenerator.generateFor(
+    void testLeafRefRelativeAndAbsoluteValidReference() {
+        final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/leafref-valid.yang"));
         assertEquals(2, types.size());
 
-        final List<MethodSignature> neighborMethods = types.stream()
+        final var neighborMethods = types.stream()
             .filter(type -> type.getName().equals("Neighbor"))
             .findFirst()
             .orElseThrow()
             .getMethodDefinitions();
         assertEquals(10, neighborMethods.size());
 
-        final MethodSignature getNeighborId = neighborMethods.stream()
+        final var getNeighborId = neighborMethods.stream()
             .filter(method -> method.getName().equals("getNeighborId"))
             .findFirst()
             .orElseThrow();
         assertEquals(Types.STRING, getNeighborId.getReturnType());
 
-        final MethodSignature getNeighbor2Id = neighborMethods.stream()
+        final var getNeighbor2Id = neighborMethods.stream()
             .filter(method -> method.getName().equals("getNeighbor2Id"))
             .findFirst()
             .orElseThrow();
index 8f5818e4d0c59d2b1a09a594f767a52d928b5230..bc85f6ae9fd2f38d0a7bb663745241b80c85e719 100644 (file)
@@ -7,24 +7,24 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
 /**
  * Test leafref resolution when the leaf is from a grouping.
  */
-public class Mdsal182Test {
+class Mdsal182Test {
     @Test
-    public void testOneUpLeafref() {
+    void testOneUpLeafref() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal-182/good-leafref.yang"));
         assertEquals(6, types.size());
     }
 
     @Test
-    public void testTwoUpLeafref() {
+    void testTwoUpLeafref() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal-182/grouping-leafref.yang"));
         assertEquals(4, types.size());
index b1c3258ab2039e6bb596e7461b5a64e9fb6e5d05..1c48302dc3ba257d934accd439ed2993bd0c72b4 100644 (file)
@@ -7,20 +7,18 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal300Test {
+class Mdsal300Test {
     @Test
-    public void testActionsAndAugmentsTest() {
-        List<GeneratedType> generateTypes = DefaultBindingGenerator.generateFor(
+    void testActionsAndAugmentsTest() {
+        final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/mdsal-300"));
-        assertNotNull(generateTypes);
-        assertEquals(19, generateTypes.size());
+        assertNotNull(types);
+        assertEquals(19, types.size());
     }
 }
index 536820f1f19e34844ab62289796f7c1c5b6e426f..409844c0d89e097d5e04bc788fc6aeb252d760fe 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal302Test {
+class Mdsal302Test {
     @Test
-    public void testRpcUsesAugment() {
+    void testRpcUsesAugment() {
         final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal302.yang"));
         assertNotNull(types);
         assertEquals(15, types.size());
index 2aa42c1875d6b323f146a527519d8b16bbdba0d3..d2bfd88ce01519234caf6f2d456825f464ae96e8 100644 (file)
@@ -7,76 +7,64 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Iterator;
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.contract.Naming;
-import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.binding.model.api.MethodSignature;
-import org.opendaylight.yangtools.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal320Test {
+class Mdsal320Test {
     @Test
-    public void mdsal320Test() {
+    void mdsal320Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal320.yang"));
         assertEquals(2, generateTypes.size());
 
-        final GeneratedType foo = generateTypes.stream().filter(type -> type.getFullyQualifiedName()
+        final var foo = generateTypes.stream().filter(type -> type.getFullyQualifiedName()
             .equals("org.opendaylight.yang.gen.v1.urn.odl.yt320.norev.Foo")).findFirst().orElseThrow();
 
-        final List<GeneratedType> fooTypes = foo.getEnclosedTypes();
+        final var fooTypes = foo.getEnclosedTypes();
         assertEquals(1, fooTypes.size());
 
-        final GeneratedType bar = fooTypes.get(0);
+        final var bar = assertInstanceOf(GeneratedTransferObject.class, fooTypes.getFirst());
         assertEquals("Bar", bar.getName());
-        assertThat(bar, instanceOf(GeneratedTransferObject.class));
-        assertTrue(((GeneratedTransferObject) bar).isUnionType());
+        assertTrue(bar.isUnionType());
 
-        final List<GeneratedType> barTypes = bar.getEnclosedTypes();
+        final var barTypes = bar.getEnclosedTypes();
         assertEquals(1, barTypes.size());
 
-        final GeneratedType bar1 = barTypes.get(0);
+        final var bar1 = assertInstanceOf(GeneratedTransferObject.class, barTypes.getFirst());
         assertEquals("Bar$1", bar1.getName());
-        assertThat(bar1, instanceOf(GeneratedTransferObject.class));
-        assertTrue(((GeneratedTransferObject) bar1).isUnionType());
+        assertTrue(bar1.isUnionType());
 
-        final Iterator<MethodSignature> it = foo.getMethodDefinitions().iterator();
+        final var it = foo.getMethodDefinitions().iterator();
         assertTrue(it.hasNext());
-        final MethodSignature getImplIface = it.next();
+        final var getImplIface = it.next();
         assertEquals("implementedInterface", getImplIface.getName());
         assertTrue(getImplIface.isDefault());
         assertTrue(it.hasNext());
 
-        final MethodSignature bindingHashCode = it.next();
+        final var bindingHashCode = it.next();
         assertEquals(Naming.BINDING_HASHCODE_NAME, bindingHashCode.getName());
-        final MethodSignature bindingEquals = it.next();
+        final var bindingEquals = it.next();
         assertEquals(Naming.BINDING_EQUALS_NAME, bindingEquals.getName());
-        final MethodSignature bindingToString = it.next();
+        final var bindingToString = it.next();
         assertEquals(Naming.BINDING_TO_STRING_NAME, bindingToString.getName());
-        final MethodSignature getBar = it.next();
-        final Type getBarType = getBar.getReturnType();
-        assertTrue(getBarType instanceof GeneratedTransferObject);
-        final GeneratedTransferObject getBarTO = (GeneratedTransferObject) getBarType;
-        assertTrue(getBarTO.isUnionType());
-        assertEquals(bar, getBarTO);
-        final MethodSignature requireBar = it.next();
-        assertThat(requireBar.getName(), startsWith(Naming.REQUIRE_PREFIX));
+        final var getBar = it.next();
+        final var getBarType = assertInstanceOf(GeneratedTransferObject.class, getBar.getReturnType());
+        assertTrue(getBarType.isUnionType());
+        assertEquals(bar, getBarType);
+        final var requireBar = it.next();
+        assertThat(requireBar.getName()).startsWith(Naming.REQUIRE_PREFIX);
         assertFalse(it.hasNext());
 
-        final GeneratedProperty bar1Prop = bar.getProperties().stream().filter(prop -> "bar$1".equals(prop.getName()))
+        final var bar1Prop = bar.getProperties().stream().filter(prop -> "bar$1".equals(prop.getName()))
                 .findFirst().orElseThrow();
-        final Type bar1PropRet = bar1Prop.getReturnType();
-        assertEquals(bar1, bar1PropRet);
+        assertEquals(bar1, bar1Prop.getReturnType());
     }
 }
index 7b4cfe0364e91c16c03380d219c62054e3674deb..c5813851376e3cba0648316c3e1cb433ebcc3a9f 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class Mdsal324Test {
+class Mdsal324Test {
     @Test
-    public void mdsal324Test() {
+    void mdsal324Test() {
         final var generatedTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal324.yang"));
         assertEquals(2, generatedTypes.size());
index 67276f77a03f6026ef3d8a989019a9eb9b00263f..040cc5270af1fc2ac56a7a7dc1859d919deb3758 100644 (file)
@@ -7,26 +7,25 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import org.junit.Test;
+import java.util.List;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal332Test {
+class Mdsal332Test {
     @Test
-    public void mdsal332Test() {
+    void mdsal332Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal332.yang"));
         assertNotNull(generateTypes);
         assertEquals(5, generateTypes.size());
 
-        final var names = generateTypes.stream().map(GeneratedType::getIdentifier)
-                .collect(ImmutableList.toImmutableList());
+        final var names = generateTypes.stream().map(GeneratedType::getIdentifier).toList();
         final var uniqueNames = ImmutableSet.copyOf(names);
-        assertEquals(ImmutableList.copyOf(uniqueNames), names);
+        assertEquals(List.copyOf(uniqueNames), names);
     }
 }
index 0789885cdc09f2854fc77661fcc5cc580601a37b..6554699a88f6803783704fa55481cd25206bca4a 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal335Test {
+class Mdsal335Test {
     @Test
-    public void mdsal335Test() {
+    void mdsal335Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal335.yang"));
         assertNotNull(generateTypes);
index 549f47242607848e8d372b5d07f41d76ce1888c9..11671dd0596b58e127a9081251d370e85fc4ff4f 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal352Test {
+class Mdsal352Test {
     @Test
-    public void mdsal352Test() {
+    void mdsal352Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal352.yang"));
         assertNotNull(generateTypes);
index a3bba8d844da0c677e90b38bef2214e4ee71c159..75e7f396fd98b35606c70b57139cbf7a8d67f516 100644 (file)
@@ -7,35 +7,35 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 static org.opendaylight.yangtools.binding.model.ri.BindingTypes.BITS_TYPE_OBJECT;
 import static org.opendaylight.yangtools.binding.model.ri.BindingTypes.UNION_TYPE_OBJECT;
 
-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.binding.model.ri.BindingTypes;
 import org.opendaylight.yangtools.binding.model.ri.Types;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal406TypeObjectTest {
+class Mdsal406TypeObjectTest {
     private static EffectiveModelContext CONTEXT;
 
-    @BeforeClass
-    public static void beforeClass() {
+    @BeforeAll
+    static void beforeClass() {
         CONTEXT = YangParserTestUtils.parseYangResources(ExtendedTypedefTest.class,
             "/type-provider/test.yang", "/ietf-models/ietf-inet-types.yang");
     }
 
-    @AfterClass
-    public static void afterClass() {
+    @AfterAll
+    static void afterClass() {
         CONTEXT = null;
     }
 
     @Test
-    public void typeObjectTest() {
+    void typeObjectTest() {
         final var generateTypes = DefaultBindingGenerator.generateFor(CONTEXT);
         assertNotNull(generateTypes);
 
@@ -51,7 +51,7 @@ public class Mdsal406TypeObjectTest {
     }
 
     @Test
-    public void bitsTypeObjectForBitsTypedefTest() {
+    void bitsTypeObjectForBitsTypedefTest() {
         final var generateTypes = DefaultBindingGenerator.generateFor(CONTEXT);
         assertNotNull(generateTypes);
 
@@ -67,7 +67,7 @@ public class Mdsal406TypeObjectTest {
     }
 
     @Test
-    public void typeObjectForUnionTypedefTest() {
+    void typeObjectForUnionTypedefTest() {
         final var generateTypes = DefaultBindingGenerator.generateFor(CONTEXT);
         assertNotNull(generateTypes);
 
index 8ae29710637954fdcac574be938911820cd54c8b..84894df1bcaa39ea86f40d7ce5e939996200cb3e 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal437Test extends AbstractOpaqueTest {
+class Mdsal437Test extends AbstractOpaqueTest {
     @Test
-    public void generateAnyxmlTest() {
+    void generateAnyxmlTest() {
         final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal437.yang"));
         assertNotNull(types);
         assertEquals(7, types.size());
index c01f822ee1bbe6a13ac9176a105a0697880fa884..c13436ff55bc595c3cf2560ce81fe7a35af51c79 100644 (file)
@@ -7,19 +7,16 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.util.List;
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.model.api.GeneratedType;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal438Test extends AbstractOpaqueTest {
+class Mdsal438Test extends AbstractOpaqueTest {
     @Test
-    public void generateAnydataTest() {
-        final List<GeneratedType> types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
-            "/mdsal438.yang"));
+    void generateAnydataTest() {
+        final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal438.yang"));
         assertNotNull(types);
         assertEquals(7, types.size());
 
index 2f1e370ae9e860bc9688348d7d56b5ea2be189a0..3b0bc2829fb3d836cf3902ddee196c0b75e07b57 100644 (file)
@@ -7,24 +7,24 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-import com.google.common.collect.ImmutableSet;
+import java.util.Set;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal458Test {
+class Mdsal458Test {
     @Test
-    public void testNestedClassFallback() {
+    void testNestedClassFallback() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal458.yang"));
         assertEquals(2, types.size());
 
         final var typeNames = types.stream().map(GeneratedType::getIdentifier).collect(Collectors.toSet());
-        assertEquals(ImmutableSet.of(
+        assertEquals(Set.of(
             JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal458.norev", "ExportedTo"),
             JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal458.norev", "Mdsal458Data")), typeNames);
     }
index 178e372b9b5420328571a1e798bca6647dc6cb06..82e4621d1313f4b74da59f01e07a75e4be3ab3e8 100644 (file)
@@ -7,26 +7,26 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 com.google.common.collect.ImmutableSet;
+import java.util.Set;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal459Test {
+class Mdsal459Test {
     @Test
-    public void testAugmentedAction() {
+    void testAugmentedAction() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/mdsal-459/"));
         assertNotNull(types);
         assertEquals(7, types.size());
 
         final var typeNames = types.stream().map(GeneratedType::getIdentifier).collect(Collectors.toSet());
-        assertEquals(ImmutableSet.of(
+        assertEquals(Set.of(
             JavaTypeName.create("org.opendaylight.yang.gen.v1.base.norev", "Foo"),
             JavaTypeName.create("org.opendaylight.yang.gen.v1.base.norev", "BaseData"),
             JavaTypeName.create("org.opendaylight.yang.gen.v1.aug.norev", "AugData"),
index 5664c3f275ac8f435b6cdeaca86e2625ca7bf89e..644499583317a1e452e5a6add40eccfec0b7877b 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal499Test {
+class Mdsal499Test {
     @Test
-    public void testSubmoduleImport() {
+    void testSubmoduleImport() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/mdsal-499"));
         assertNotNull(generateTypes);
index 5977f13a8a5f86cd22dbdc4d7e1265086aa1a171..cdb136852244aa5d1d1ccc854eb2c35611fbf1a2 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal500Test {
+class Mdsal500Test {
     @Test
-    public void testAugmentedAction() {
+    void testAugmentedAction() {
         final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal500.yang"));
         assertNotNull(types);
         assertEquals(4, types.size());
index 69fc8cf5258967dc3dc82eaadc66e9dc0d0312c5..e1e67439a7a97e2efc4c9d081ed65f87bb1a534d 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal506Test extends AbstractOpaqueTest {
+class Mdsal506Test extends AbstractOpaqueTest {
     @Test
-    public void generateAnydataTest() {
+    void generateAnydataTest() {
         final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal506.yang"));
         assertNotNull(types);
         assertEquals(4, types.size());
index 2b1363b55027dcd8d9fcfb965fae5492fb7915a6..9628d6a55c4e1997b1b4fd352cf869aaf8b2513f 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal516Test {
+class Mdsal516Test {
     @Test
-    public void testGroupingActionType() {
+    void testGroupingActionType() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/mdsal-516"));
         assertNotNull(types);
index 4c07526383cf2248f7d4bf91a8f069037f59ce8d..92a012a2742f7623ce370da585c5182f89afc588 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal517Test extends AbstractOpaqueTest {
+class Mdsal517Test extends AbstractOpaqueTest {
     @Test
-    public void augmentActionInputInGroupingTest() {
+    void augmentActionInputInGroupingTest() {
         final var types = DefaultBindingGenerator.generateFor(
                 YangParserTestUtils.parseYangResourceDirectory("/mdsal-517"));
         assertNotNull(types);
index bd6ed7afb30eaa1fc81952a041c3a0ac6c0787f4..ce6c5702bb2d59087cc9fad0ccb0a2fde61181a6 100644 (file)
@@ -7,18 +7,18 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 /**
  * Test specific combination of leafrefs, grouping and relative paths.
  */
-public class Mdsal519Test {
+class Mdsal519Test {
     @Test
-    public void testNestedLeafref2() {
+    void testNestedLeafref2() {
         final var types = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal519.yang"));
         assertNotNull(types);
index 979195c238fed3a06340398aa499bcb1660129da..a5ac8cc5f0ea9205c253ba3ce4fec2c3d6618ef3 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal531Test extends AbstractOpaqueTest {
+class Mdsal531Test extends AbstractOpaqueTest {
     @Test
-    public void augmentGroupingTest() {
+    void augmentGroupingTest() {
         final var types = DefaultBindingGenerator.generateFor(
                 YangParserTestUtils.parseYangResourceDirectory("/mdsal-531"));
         assertNotNull(types);
index 6f3554c89298a8fe41edf42e34cd0bd2982b368a..23f538d09757cd578beed55c862a1d871e3cd46c 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal552Test {
+class Mdsal552Test {
     private static final JavaTypeName BAR_INPUT =
             JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal552.norev", "BarInput");
     private static final JavaTypeName BAZ =
@@ -23,7 +23,7 @@ public class Mdsal552Test {
             JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal552.norev", "Mdsal552Data").createEnclosed("Foo");
 
     @Test
-    public void enumLeafrefTest() {
+    void enumLeafrefTest() {
         final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal552.yang"));
         assertNotNull(types);
         assertEquals(5, types.size());
index d9a5a81aeb461307ab770b80378ddae8791adcea..5f7bc4c356c94a8bf45ab2f3bd3b1de6798c3dc5 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal554Test {
+class Mdsal554Test {
     @Test
-    public void builderTemplateGenerateListenerMethodsTest() {
+    void builderTemplateGenerateListenerMethodsTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal554.yang"));
         assertEquals(4, genTypes.size());
index 906ae865287a4c9014b8166f6c7c0f0a15a74e1d..25d8292467d573f6f931c4acf4ecb1baa87a6d89 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class Mdsal572Test {
+class Mdsal572Test {
     @Test
-    public void mdsal572Test() {
+    void mdsal572Test() {
         final var types = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource("/mdsal572.yang"));
         assertEquals(5, types.size());
     }
index 88d2f2330f964ddef9a28d2098b17f6addb26726..ea216ac08ea13f13583aa07e89766299e044beb0 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal573Test {
+class Mdsal573Test {
     @Test
-    public void mdsal573Test() {
+    void mdsal573Test() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal573.yang"));
         assertNotNull(generateTypes);
         assertEquals(7, generateTypes.size());
 
-        final var methodSignature = generateTypes.get(0).getMethodDefinitions().get(0);
+        final var methodSignature = generateTypes.getFirst().getMethodDefinitions().getFirst();
         assertEquals("implementedInterface", methodSignature.getName());
     }
 }
index b645bb267a0ca4eadb428ebb9b4764a7fcb6d061..c06dd6b8cae383ca39e28df3c491e0142aeab0c5 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -20,21 +21,23 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 @NonNullByDefault
-public class Mdsal600Test {
+class Mdsal600Test {
     private static final JavaTypeName FOO = JavaTypeName.create("org.opendaylight.yang.gen.v1.mdsal600.norev", "Foo");
 
     @Test
-    public void mdsal600Test() {
+    void mdsal600Test() {
         final var models = YangParserTestUtils.parseYangResource("/mdsal600.yang");
         final var module = models.getModules().iterator().next();
         final var fooSchema = (ContainerSchemaNode) module.findDataTreeChild(QName.create("mdsal600", "foo"))
             .orElseThrow();
 
         // Verify leaves
-        final var barSchema = fooSchema.findDataTreeChild(QName.create("mdsal600", "bar")).orElseThrow();
-        final var bazSchema = fooSchema.findDataTreeChild(QName.create("mdsal600", "baz")).orElseThrow();
-        final var barTypeSchema = ((LeafSchemaNode) barSchema).getType();
-        final var bazTypeSchema = ((LeafSchemaNode) bazSchema).getType();
+        final var barSchema = assertInstanceOf(LeafSchemaNode.class,
+            fooSchema.findDataTreeChild(QName.create("mdsal600", "bar")).orElseThrow());
+        final var bazSchema = assertInstanceOf(LeafSchemaNode.class,
+            fooSchema.findDataTreeChild(QName.create("mdsal600", "baz")).orElseThrow());
+        final var barTypeSchema = barSchema.getType();
+        final var bazTypeSchema = bazSchema.getType();
 
         // Precondition to our bug: the two types compare as equal, but are not the same
         assertEquals(barTypeSchema, bazTypeSchema);
index 4d2770a522ca626b5629f3be27ba1ee222298a41..a018ed5e8fdf1803e6864964f3dd05e3ded1d584 100644 (file)
@@ -7,33 +7,33 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal666Test {
+class Mdsal666Test {
     private static final JavaTypeName FOO = JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev", "Foo");
     private static final JavaTypeName FOO_GRP = JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev", "Foo$G");
     private static final JavaTypeName BAZ_GRP = JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.bar",
         "Baz$G");
 
     @Test
-    public void rpcPushesGrouping() {
+    void rpcPushesGrouping() {
         final var generatedNames = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/mdsal666.yang")).stream().map(GeneratedType::getIdentifier)
             .collect(Collectors.toUnmodifiableList());
         assertEquals(10, generatedNames.size());
 
         // 'rpc foo' ...
-        assertTrue(generatedNames.stream().anyMatch(FOO::equals));
+        assertThat(generatedNames).anyMatch(FOO::equals);
         // ... grouping is relocated for 'rpc foo' ...
-        assertTrue(generatedNames.stream().anyMatch(FOO_GRP::equals));
+        assertThat(generatedNames).anyMatch(FOO_GRP::equals);
         // .. and 'action baz'
-        assertTrue(generatedNames.stream().anyMatch(BAZ_GRP::equals));
+        assertThat(generatedNames).anyMatch(BAZ_GRP::equals);
     }
 }
index d676bb1be763045567c23aa6c9814b9882b7c519..3d10227168150bbada12e5b52755d89f13e2dae4 100644 (file)
@@ -7,18 +7,16 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.in;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.google.common.collect.ImmutableMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.function.Function;
 import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.binding.model.api.Type;
@@ -27,7 +25,7 @@ import org.opendaylight.yangtools.binding.model.ri.BindingTypes;
 import org.opendaylight.yangtools.binding.model.ri.Types;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal675Test {
+class Mdsal675Test {
     private static final String PACKAGE = "org.opendaylight.yang.gen.v1.urn.test.yang.data.demo.norev.";
     private static final String PACKAGE2 = "org.opendaylight.yang.gen.v1.urn.test.yang.data.naming.norev.";
     private static final String MODULE_CLASS_NAME = PACKAGE + "YangDataDemoData";
@@ -36,14 +34,14 @@ public class Mdsal675Test {
             Map.of("implementedInterface", Types.typeForClass(Class.class));
 
     @Test
-    public void yangDataGen() {
-        final List<GeneratedType> allGenTypes = DefaultBindingGenerator.generateFor(
+    void yangDataGen() {
+        final var allGenTypes = DefaultBindingGenerator.generateFor(
                 YangParserTestUtils.parseYangResources(Mdsal675Test.class,
                         "/yang-data-models/ietf-restconf.yang", "/yang-data-models/yang-data-demo.yang"));
         assertNotNull(allGenTypes);
         assertEquals(29, allGenTypes.size());
-        final Map<String, GeneratedType> genTypesMap = allGenTypes.stream()
-                .collect(ImmutableMap.toImmutableMap(type -> type.getIdentifier().toString(), type -> type));
+        final var genTypesMap = allGenTypes.stream()
+            .collect(ImmutableMap.toImmutableMap(type -> type.getIdentifier().toString(), Function.identity()));
 
         // ensure generated yang-data classes contain getters for inner structure types
 
@@ -119,64 +117,62 @@ public class Mdsal675Test {
                 List.of("getAnyxmlFromGroup", "requireAnyxmlFromGroup"));
 
         // ensure module class has only getter for root container
-        final GeneratedType moduleType = assertGenType(genTypesMap, MODULE_CLASS_NAME);
+        final var moduleType = assertGenType(genTypesMap, MODULE_CLASS_NAME);
         assertNotNull(moduleType.getMethodDefinitions());
         assertEquals(List.of("getRootContainer"),
                 moduleType.getMethodDefinitions().stream().map(MethodSignature::getName)
                         .filter(methodName -> methodName.startsWith("get")).toList());
 
         // ensure yang-data at non-top level is ignored (no getters in parent container)
-        GeneratedType rootContainerType = assertGenType(genTypesMap, ROOT_CONTAINER_CLASS_NAME);
+        final var rootContainerType = assertGenType(genTypesMap, ROOT_CONTAINER_CLASS_NAME);
         assertNotNull(rootContainerType.getMethodDefinitions());
-        assertTrue(rootContainerType.getMethodDefinitions().stream()
-                .filter(method -> method.getName().startsWith("get"))
-                .findFirst().isEmpty());
+        assertThat(rootContainerType.getMethodDefinitions()).noneMatch(method -> method.getName().startsWith("get"));
     }
 
     @Test
-    public void yangDataNamingStrategy() {
-        final List<GeneratedType> allGenTypes = DefaultBindingGenerator.generateFor(
+    void yangDataNamingStrategy() {
+        final var allGenTypes = DefaultBindingGenerator.generateFor(
                 YangParserTestUtils.parseYangResources(Mdsal675Test.class,
                         "/yang-data-models/ietf-restconf.yang", "/yang-data-models/yang-data-naming.yang"));
         assertNotNull(allGenTypes);
         assertEquals(22, allGenTypes.size());
-        final Set<String> genTypeNames =
-                allGenTypes.stream().map(type -> type.getIdentifier().toString()).collect(Collectors.toSet());
+        final var genTypeNames = allGenTypes.stream().map(type -> type.getIdentifier().toString())
+            .collect(Collectors.toSet());
 
         // template name is not compliant to YANG identifier -> char encoding used, name starts with $ char
         // a) latin1, but not a valid Java identifier
-        assertTrue(genTypeNames.contains(PACKAGE2 + "$ľaľa$20$ho$2C$$20$papľuha$2C$$20$ogrcal$20$mi$20$krpce$21$"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "$ľaľa$20$ho$2C$$20$papľuha$2C$$20$ogrcal$20$mi$20$krpce$21$");
         // b) cyrillic, but a valid Java identifier
-        assertTrue(genTypeNames.contains(PACKAGE2 + "привет"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "привет");
 
         // template name is compliant to yang identifier -> camel-case used
-        assertTrue(genTypeNames.contains(PACKAGE2 + "IdentifierCompliantName"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "IdentifierCompliantName");
 
         // name collision with a typedef
-        assertTrue(genTypeNames.contains(PACKAGE2 + "Collision1$T"));
-        assertTrue(genTypeNames.contains(PACKAGE2 + "collision1.Collision1"));
-        assertTrue(genTypeNames.contains(PACKAGE2 + "Collision1$YD"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "Collision1$T");
+        assertThat(genTypeNames).contains(PACKAGE2 + "collision1.Collision1");
+        assertThat(genTypeNames).contains(PACKAGE2 + "Collision1$YD");
 
         // name collision with top level container
-        assertTrue(genTypeNames.contains(PACKAGE2 + "Collision2"));
-        assertTrue(genTypeNames.contains(PACKAGE2 + "Collision2$YD"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "Collision2");
+        assertThat(genTypeNames).contains(PACKAGE2 + "Collision2$YD");
 
         // name collision with group used
-        assertTrue(genTypeNames.contains(PACKAGE2 + "Collision3$G"));
-        assertTrue(genTypeNames.contains(PACKAGE2 + "Collision3$YD"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "Collision3$G");
+        assertThat(genTypeNames).contains(PACKAGE2 + "Collision3$YD");
 
         // rc:yang-data .-/#
-        assertTrue(genTypeNames.contains(PACKAGE2 + "$$2E$$2D$$2F$$23$"));
-        assertTrue(genTypeNames.contains(PACKAGE2 + "$$2e$$2d$$2f$$23$$.Foo"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "$$2E$$2D$$2F$$23$");
+        assertThat(genTypeNames).contains(PACKAGE2 + "$$2e$$2d$$2f$$23$$.Foo");
 
         // rc:yang-data -./#
-        assertTrue(genTypeNames.contains(PACKAGE2 + "$$2D$$2E$$2F$$23$"));
-        assertTrue(genTypeNames.contains(PACKAGE2 + "$$2d$$2e$$2f$$23$$.Foo"));
+        assertThat(genTypeNames).contains(PACKAGE2 + "$$2D$$2E$$2F$$23$");
+        assertThat(genTypeNames).contains(PACKAGE2 + "$$2d$$2e$$2f$$23$$.Foo");
     }
 
     private static GeneratedType assertGenType(final Map<String, GeneratedType> genTypesMap, final String className) {
         final var ret = genTypesMap.get(className);
-        assertNotNull("no type generated: " + className, ret);
+        assertNotNull(ret, "no type generated: " + className);
         return ret;
     }
 
@@ -201,13 +197,11 @@ public class Mdsal675Test {
 
     private static void assertHasMethod(final GeneratedType genType, final String methodName,
             final Type returnType) {
-        assertTrue("no expected method " + methodName + " returning " + returnType,
-            genType.getMethodDefinitions().stream().anyMatch(
-                method -> methodName.equals(method.getName()) && returnType.equals(method.getReturnType())));
+        assertThat(genType.getMethodDefinitions())
+            .anyMatch(method -> methodName.equals(method.getName()) && returnType.equals(method.getReturnType()));
     }
 
     private static void assertImplements(final GeneratedType genType, final Type implementedType) {
-        assertThat(implementedType, in(genType.getImplements()));
+        assertThat(genType.getImplements()).contains(implementedType);
     }
-
 }
index b75fd81a8a03e78bfcf010e5017e0986accffce2..32463ccdf03de98d1180036f02d51648004eddd1 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class Mdsal715Test {
+class Mdsal715Test {
     @Test
-    public void testAugmentLinking() {
+    void testAugmentLinking() {
         final var generatedTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/mdsal715"));
         assertEquals(15, generatedTypes.size());
index ac87210aecaba3b24ad685e95aac6c8ec27f39dd..6352c998f0c18d4bb75f8673a53ec8cdb5553059 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.test.util.YangParserTestUtils;
 
-public class Mdsal718Test {
+class Mdsal718Test {
     @Test
-    public void testModuleUsesAugmentLinking() {
+    void testModuleUsesAugmentLinking() {
         final var generatedTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResourceDirectory("/mdsal718"));
         assertEquals(13, generatedTypes.size());
index 682cb1624ff64e06ed0ae04f5a58f084c5e37133..f1913f908689e77d946f41e7f2f5aadb3ffa9393 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal810Test {
+class Mdsal810Test {
     @Test
-    public void testKeyConflict() {
+    void testKeyConflict() {
         assertGeneratedNames("key-conflict.yang",
             "org.opendaylight.yang.gen.v1.key.conflict.norev.KeyConflictData",
             "org.opendaylight.yang.gen.v1.key.conflict.norev.Foo$LI",
@@ -24,7 +24,7 @@ public class Mdsal810Test {
     }
 
     @Test
-    public void testListenerConflict() {
+    void testListenerConflict() {
         assertGeneratedNames("listener-conflict.yang",
             "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictData",
             "org.opendaylight.yang.gen.v1.listener.conflict.norev.ListenerConflictListener",
@@ -32,14 +32,14 @@ public class Mdsal810Test {
     }
 
     @Test
-    public void testRootConflict() {
+    void testRootConflict() {
         assertGeneratedNames("root-conflict.yang",
             "org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData",
             "org.opendaylight.yang.gen.v1.root.conflict.norev.RootConflictData$CO");
     }
 
     @Test
-    public void testServiceConflict() {
+    void testServiceConflict() {
         assertGeneratedNames("service-conflict.yang",
             "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictData",
             "org.opendaylight.yang.gen.v1.service.conflict.norev.ServiceConflictService",
@@ -49,7 +49,7 @@ public class Mdsal810Test {
     }
 
     @Test
-    public void testInputOutputConflict() {
+    void testInputOutputConflict() {
         assertGeneratedNames("io-conflict.yang",
             "org.opendaylight.yang.gen.v1.io.conflict.norev.IoConflictData",
             "org.opendaylight.yang.gen.v1.io.conflict.norev.Foo$RP",
@@ -60,7 +60,7 @@ public class Mdsal810Test {
     }
 
     @Test
-    public void testSchemaCollisions() {
+    void testSchemaCollisions() {
         assertGeneratedNames("schema-conflict.yang",
             "org.opendaylight.yang.gen.v1.schema.conflict.norev.SchemaConflictData",
             "org.opendaylight.yang.gen.v1.schema.conflict.norev.FooBar$AD",
index 260f9fa27274d02c84fcaa0df8e138226fd60c4e..2ca4ef8b6eb1ce2df79a18906225f782385215de 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.binding.runtime.api.ActionRuntimeType;
 import org.opendaylight.yangtools.binding.runtime.api.ContainerRuntimeType;
@@ -23,36 +22,36 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal824Test {
+class Mdsal824Test {
     private static EffectiveModelContext CONTEXT;
 
-    @BeforeClass
-    public static void beforeClass() {
+    @BeforeAll
+    static void beforeClass() {
         CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/mdsal824");
     }
 
     @Test
-    public void testCompileTimeTypes() {
+    void testCompileTimeTypes() {
         assertEquals(13, DefaultBindingGenerator.generateFor(CONTEXT).size());
     }
 
     @Test
-    public void testRunTimeTypes() {
+    void testRunTimeTypes() {
         final var types = BindingRuntimeTypesFactory.createTypes(CONTEXT);
-        final var barTop = types.schemaTreeChild(QName.create("bar", "bar-top"));
-        assertThat(barTop, instanceOf(ContainerRuntimeType.class));
-        final var barList = ((ContainerRuntimeType) barTop).schemaTreeChild(QName.create("bar", "bar-list"));
-        assertThat(barList, instanceOf(ListRuntimeType.class));
-        final var barAction = ((ListRuntimeType) barList).schemaTreeChild(QName.create("bar", "foo"));
-        assertThat(barAction, instanceOf(ActionRuntimeType.class));
-
-        final var barInput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "input"));
-        assertThat(barInput, instanceOf(InputRuntimeType.class));
+        final var barTop = assertInstanceOf(ContainerRuntimeType.class,
+            types.schemaTreeChild(QName.create("bar", "bar-top")));
+        final var barList = assertInstanceOf(ListRuntimeType.class,
+            barTop.schemaTreeChild(QName.create("bar", "bar-list")));
+        final var barAction = assertInstanceOf(ActionRuntimeType.class,
+            barList.schemaTreeChild(QName.create("bar", "foo")));
+
+        final var barInput = assertInstanceOf(InputRuntimeType.class,
+            barAction.schemaTreeChild(QName.create("bar", "input")));
         assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooInput"),
             barInput.javaType().getIdentifier());
 
-        final var barOutput = ((ActionRuntimeType) barAction).schemaTreeChild(QName.create("bar", "output"));
-        assertThat(barOutput, instanceOf(OutputRuntimeType.class));
+        final var barOutput = assertInstanceOf(OutputRuntimeType.class,
+            barAction.schemaTreeChild(QName.create("bar", "output")));
         assertEquals(JavaTypeName.create("org.opendaylight.yang.gen.v1.foo.norev.act.grp", "FooOutput"),
             barOutput.javaType().getIdentifier());
     }
index a2b6009c1db08346b468c112b18eb59a6a0593a6..267be03646c792b4e4ca7a6649f248634123827c 100644 (file)
@@ -7,27 +7,27 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class Mdsal829Test {
+class Mdsal829Test {
     private static final EffectiveModelContext MODEL_CONTEXT =
         YangParserTestUtils.parseYangResource("/mdsal829.yang", Set.of());
 
     @Test
-    public void testCompileTimeTypes() {
+    void testCompileTimeTypes() {
         assertEquals(1, DefaultBindingGenerator.generateFor(MODEL_CONTEXT).size());
     }
 
     @Test
-    public void testRunTimeTypes() {
+    void testRunTimeTypes() {
         final var types = BindingRuntimeTypesFactory.createTypes(MODEL_CONTEXT);
         assertSame(MODEL_CONTEXT, types.modelContext());
         final var schema = types.findSchema(
index 9163615727e693853dfb4342e110b20f6cb1549e..6eab54e4e27b607a17cbb4e7a340c8bb284a667e 100644 (file)
@@ -7,27 +7,25 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 java.io.Serializable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.generator.impl.reactor.SerialVersionHelper;
 import org.opendaylight.yangtools.binding.model.api.AccessModifier;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
-import org.opendaylight.yangtools.binding.model.api.type.builder.GeneratedTypeBuilder;
-import org.opendaylight.yangtools.binding.model.api.type.builder.MethodSignatureBuilder;
 import org.opendaylight.yangtools.binding.model.ri.Types;
 import org.opendaylight.yangtools.binding.model.ri.generated.type.builder.CodegenGeneratedTOBuilder;
 import org.opendaylight.yangtools.binding.model.ri.generated.type.builder.CodegenGeneratedTypeBuilder;
 
-public class SerialVersionHelperTest {
+class SerialVersionHelperTest {
     @Test
-    public void computeDefaultSUIDTest() {
-        CodegenGeneratedTypeBuilder generatedTypeBuilder = new CodegenGeneratedTypeBuilder(
+    void computeDefaultSUIDTest() {
+        final var generatedTypeBuilder = new CodegenGeneratedTypeBuilder(
             JavaTypeName.create("my.package", "MyName"));
 
-        MethodSignatureBuilder method = generatedTypeBuilder.addMethod("myMethodName");
+        final var method = generatedTypeBuilder.addMethod("myMethodName");
         method.setAccessModifier(AccessModifier.PUBLIC);
         generatedTypeBuilder.addProperty("myProperty");
         generatedTypeBuilder.addImplementsType(Types.typeForClass(Serializable.class));
@@ -36,21 +34,21 @@ public class SerialVersionHelperTest {
     }
 
     @Test
-    public void computeDefaultSUIDStabilityTest() {
+    void computeDefaultSUIDStabilityTest() {
         // test method computeDefaultSUID
-        GeneratedTypeBuilder genTypeBuilder = new CodegenGeneratedTypeBuilder(
+        final var genTypeBuilder = new CodegenGeneratedTypeBuilder(
             JavaTypeName.create("org.opendaylight.yangtools.test", "TestType"));
         genTypeBuilder.addMethod("testMethod");
         genTypeBuilder.addAnnotation("org.opendaylight.yangtools.test.annotation", "AnnotationTest");
         genTypeBuilder.addEnclosingTransferObject(new CodegenGeneratedTOBuilder(genTypeBuilder.getIdentifier()
             .createEnclosed("testObject")).build());
         genTypeBuilder.addProperty("newProp");
-        GeneratedTypeBuilder genType = new CodegenGeneratedTypeBuilder(
+        final var genType = new CodegenGeneratedTypeBuilder(
             JavaTypeName.create("org.opendaylight.yangtools.test", "Type2"));
         genTypeBuilder.addImplementsType(genType);
         long computedSUID = SerialVersionHelper.computeDefaultSUID(genTypeBuilder);
 
-        GeneratedTypeBuilder genTypeBuilder2 = new CodegenGeneratedTypeBuilder(
+        final var genTypeBuilder2 = new CodegenGeneratedTypeBuilder(
             JavaTypeName.create("org.opendaylight.yangtools.test2", "TestType2"));
         long computedSUID2 = SerialVersionHelper.computeDefaultSUID(genTypeBuilder2);
         assertNotEquals(computedSUID, computedSUID2);
index 3a42095b3c50d79405ecb38ed482ad5b02376b68..d0d26adda225e41bd31b97dd8767428ebdc178f6 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
 import org.opendaylight.yangtools.binding.model.api.GeneratedProperty;
@@ -18,17 +18,16 @@ import org.opendaylight.yangtools.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.binding.model.api.Type;
 
-public final class SupportTestUtil {
+final class SupportTestUtil {
     private SupportTestUtil() {
-
+        // Hidden on purpose
     }
 
-    public static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
-        final List<MethodSignature> searchedSignsIn = genType.getMethodDefinitions();
-        containsMethods(searchedSignsIn, searchedSignsWhat);
+    static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
+        containsMethods(genType.getMethodDefinitions(), searchedSignsWhat);
     }
 
-    public static void containsMethods(final List<MethodSignature> searchedSignsIn,
+    static void containsMethods(final List<MethodSignature> searchedSignsIn,
             final NameTypePattern... searchedSignsWhat) {
         if (searchedSignsIn == null) {
             throw new IllegalArgumentException("List of method signatures in which should be searched can't be null");
@@ -37,10 +36,10 @@ public final class SupportTestUtil {
             throw new IllegalArgumentException("Array of method signatures which should be searched can't be null");
         }
 
-        for (NameTypePattern searchedSignWhat : searchedSignsWhat) {
+        for (var searchedSignWhat : searchedSignsWhat) {
             boolean nameMatchFound = false;
             String typeNameFound = "";
-            for (MethodSignature searchedSignIn : searchedSignsIn) {
+            for (var searchedSignIn : searchedSignsIn) {
                 if (searchedSignWhat.getName().equals(searchedSignIn.getName())) {
                     nameMatchFound = true;
                     typeNameFound = resolveFullNameOfReturnType(searchedSignIn.getReturnType());
@@ -49,16 +48,16 @@ public final class SupportTestUtil {
                     }
                 }
             }
-            assertTrue("Method " + searchedSignWhat.getName() + " wasn't found.", nameMatchFound);
-            assertEquals("Return type in method " + searchedSignWhat.getName() + " doesn't match expected type ",
-                    searchedSignWhat.getType(), typeNameFound);
+            assertTrue(nameMatchFound, "Method " + searchedSignWhat.getName() + " wasn't found.");
+            assertEquals(searchedSignWhat.getType(), typeNameFound,
+                "Return type in method " + searchedSignWhat.getName() + " doesn't match expected type ");
 
         }
     }
 
-    public static void containsAttributes(final GeneratedTransferObject genTO, final boolean equal, final boolean hash,
+    static void containsAttributes(final GeneratedTransferObject genTO, final boolean equal, final boolean hash,
             final boolean toString, final NameTypePattern... searchedSignsWhat) {
-        List<GeneratedProperty> searchedPropertiesIn = genTO.getProperties();
+        var searchedPropertiesIn = genTO.getProperties();
         containsAttributes(searchedPropertiesIn, "", searchedSignsWhat);
         if (equal) {
             searchedPropertiesIn = genTO.getEqualsIdentifiers();
@@ -72,16 +71,15 @@ public final class SupportTestUtil {
             searchedPropertiesIn = genTO.getToStringIdentifiers();
             containsAttributes(searchedPropertiesIn, "toString", searchedSignsWhat);
         }
-
     }
 
-    public static void containsAttributes(final List<GeneratedProperty> searchedPropertiesIn, final String listType,
+    static void containsAttributes(final List<GeneratedProperty> searchedPropertiesIn, final String listType,
             final NameTypePattern... searchedPropertiesWhat) {
 
-        for (NameTypePattern searchedPropertyWhat : searchedPropertiesWhat) {
+        for (var searchedPropertyWhat : searchedPropertiesWhat) {
             boolean nameMatchFound = false;
             String typeNameFound = "";
-            for (GeneratedProperty searchedPropertyIn : searchedPropertiesIn) {
+            for (var searchedPropertyIn : searchedPropertiesIn) {
                 if (searchedPropertyWhat.getName().equals(searchedPropertyIn.getName())) {
                     nameMatchFound = true;
                     typeNameFound = resolveFullNameOfReturnType(searchedPropertyIn.getReturnType());
@@ -90,44 +88,41 @@ public final class SupportTestUtil {
                     }
                 }
             }
-            assertTrue("Property " + searchedPropertyWhat.getName() + " wasn't found in " + listType
-                    + " property list.", nameMatchFound);
-            assertEquals("The type of property " + searchedPropertyWhat.getName() + " in " + listType
-                    + " property list doesn't match expected type.", searchedPropertyWhat.getType(), typeNameFound);
-
+            assertTrue(nameMatchFound,
+                "Property " + searchedPropertyWhat.getName() + " wasn't found in " + listType + " property list.");
+            assertEquals(searchedPropertyWhat.getType(), typeNameFound,
+                "The type of property " + searchedPropertyWhat.getName() + " in " + listType
+                + " property list doesn't match expected type.");
         }
     }
 
-    public static String resolveFullNameOfReturnType(final Type type) {
-        final StringBuilder nameBuilder = new StringBuilder();
-        if (type instanceof ParameterizedType) {
-            nameBuilder.append(type.getName()).append('<');
-            ParameterizedType parametrizedTypes = (ParameterizedType) type;
-            for (Type parametrizedType : parametrizedTypes.getActualTypeArguments()) {
-                nameBuilder.append(parametrizedType.getName()).append(',');
+    static String resolveFullNameOfReturnType(final Type type) {
+        final var sb = new StringBuilder();
+        if (type instanceof ParameterizedType parameterizedTypes) {
+            sb.append(type.getName()).append('<');
+            for (var parameterizedType : parameterizedTypes.getActualTypeArguments()) {
+                sb.append(parameterizedType.getName()).append(',');
             }
-            if (nameBuilder.charAt(nameBuilder.length() - 1) == ',') {
-                nameBuilder.deleteCharAt(nameBuilder.length() - 1);
+            if (sb.charAt(sb.length() - 1) == ',') {
+                sb.deleteCharAt(sb.length() - 1);
             }
-            nameBuilder.append(">");
+            sb.append(">");
         } else {
-            nameBuilder.append(type.getName());
+            sb.append(type.getName());
         }
-        return nameBuilder.toString();
+        return sb.toString();
     }
 
-    public static void containsInterface(final String interfaceNameSearched, final GeneratedType genType) {
-        List<Type> caseCImplements = genType.getImplements();
+    static void containsInterface(final String interfaceNameSearched, final GeneratedType genType) {
+        final var caseCImplements = genType.getImplements();
         boolean interfaceFound = false;
-        for (Type caseCImplement : caseCImplements) {
-            String interfaceName = resolveFullNameOfReturnType(caseCImplement);
-            if (interfaceName.equals(interfaceNameSearched)) {
+        for (var caseCImplement : caseCImplements) {
+            if (resolveFullNameOfReturnType(caseCImplement).equals(interfaceNameSearched)) {
                 interfaceFound = true;
                 break;
             }
         }
-        assertTrue("Generated type " + genType.getName() + " doesn't implement interface " + interfaceNameSearched,
-                interfaceFound);
+        assertTrue(interfaceFound,
+            "Generated type " + genType.getName() + " doesn't implement interface " + interfaceNameSearched);
     }
-
 }
index 2e6b493c3ce0148d2e63622932b46d2facbaabb5..b449ad887cd0762266633a6f1130ce8b240e0bc1 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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.binding.model.ri.Types;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class UnionTypeDefTest {
+class UnionTypeDefTest {
     @Test
-    public void unionTypeResolvingTest() {
+    void unionTypeResolvingTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResources(
             UnionTypeDefTest.class, "/union-test-models/abstract-topology.yang", "/ietf-models/ietf-inet-types.yang"));
         assertEquals(29, genTypes.size());
@@ -24,7 +24,7 @@ public class UnionTypeDefTest {
     }
 
     @Test
-    public void unionTypedefLeafrefTest() {
+    void unionTypedefLeafrefTest() {
         final var generateTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/bug8449.yang"));
         assertEquals(5, generateTypes.size());
index 71ac14177d7d3af7a07e737231868b4f5dcc4278..296aff2d09ebdd5f00049d7e75ea0d090c4fae3d 100644 (file)
@@ -7,20 +7,19 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl;
 
-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 static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsInterface;
 import static org.opendaylight.yangtools.binding.generator.impl.SupportTestUtil.containsMethods;
 
-import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public class UsesTest {
+class UsesTest {
     @Test
-    public void usesInGroupingDependenciesTest() {
+    void usesInGroupingDependenciesTest() {
         final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-dependencies.yang"));
         GeneratedType groupingU = null;
@@ -46,20 +45,20 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for grouping-U wasn't generated.", groupingU);
-        assertEquals("GroupingU interface generated more than one time.", 1, groupingUCounter);
-        assertEquals("GroupingU is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingU.getPackageName());
+        assertNotNull(groupingU, "Generated type for grouping-U wasn't generated.");
+        assertEquals(1, groupingUCounter, "GroupingU interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingU.getPackageName(),
+            "GroupingU is in wrong package.");
 
-        assertNotNull("Generated type for grouping-V wasn't generated.", groupingV);
-        assertEquals("GroupingV interface generated more than one time.", 1, groupingVCounter);
-        assertEquals("GroupingV is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingV.getPackageName());
+        assertNotNull(groupingV, "Generated type for grouping-V wasn't generated.");
+        assertEquals(1, groupingVCounter, "GroupingV interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingV.getPackageName(),
+            "GroupingV is in wrong package.");
 
-        assertNotNull("Generated type for grouping-X wasn't generated.", groupingX);
-        assertEquals("GroupingX interface generated more than one time.", 1, groupingXCounter);
-        assertEquals("GroupingX is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingX.getPackageName());
+        assertNotNull(groupingX, "Generated type for grouping-X wasn't generated.");
+        assertEquals(1, groupingXCounter, "GroupingX interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingX.getPackageName(),
+            "GroupingX is in wrong package.");
 
         containsInterface("GroupingV", groupingU);
         containsInterface("GroupingX", groupingU);
@@ -69,15 +68,15 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInCaseTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void usesInCaseTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/uses-of-grouping/uses-of-grouping-case.yang"));
 
         GeneratedType groupingCaseTest = null;
         int groupingCaseTestCounter = 0;
         GeneratedType caseC = null;
         int caseCCounter = 0;
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("C")) {
                     caseC = genType;
@@ -89,32 +88,32 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for case C wasn't generated.", caseC);
-        assertEquals("Case C interface generated more than one time.", 1, caseCCounter);
+        assertNotNull(caseC, "Generated type for case C wasn't generated.");
+        assertEquals(1, caseCCounter, "Case C interface generated more than one time.");
         assertEquals(
-                "Case C is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718.container.with.choicetest.choice.test",
-                caseC.getPackageName());
+            "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718.container.with.choicetest.choice.test",
+            caseC.getPackageName(),
+            "Case C is in wrong package.");
 
-        assertNotNull("Generated type for grouping-case-test wasn't generated.", groupingCaseTest);
-        assertEquals("GroupingCaseTest interface generated more than one time.", 1, groupingCaseTestCounter);
-        assertEquals("GroupingCaseTest is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718", groupingCaseTest.getPackageName());
+        assertNotNull(groupingCaseTest, "Generated type for grouping-case-test wasn't generated.");
+        assertEquals(1, groupingCaseTestCounter, "GroupingCaseTest interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718",
+            groupingCaseTest.getPackageName(), "GroupingCaseTest is in wrong package.");
 
         containsInterface("GroupingCaseTest", caseC);
         // FIXME: split this into getter/default/static asserts
         assertEquals(4, caseC.getMethodDefinitions().size());
 
-        assertEquals("Number of method in GroupingCaseTest is incorrect", 2, groupingCaseTest.getMethodDefinitions()
-                .size());
+        assertEquals(2, groupingCaseTest.getMethodDefinitions().size(),
+            "Number of method in GroupingCaseTest is incorrect");
         containsMethods(groupingCaseTest.getMethodDefinitions(),
             new NameTypePattern("getLeafGroupingCaseTest1", "String"),
             new NameTypePattern("requireLeafGroupingCaseTest1", "String"));
     }
 
     @Test
-    public void usesInContainerTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void usesInContainerTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/uses-of-grouping/uses-of-grouping-container.yang"));
 
         int containerTestCount = 0;
@@ -122,7 +121,7 @@ public class UsesTest {
         GeneratedType containerTest = null;
         GeneratedType groupingContainerTest = null;
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("GroupingContainerTest")) {
                     groupingContainerTest = genType;
@@ -134,22 +133,21 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for grouping-container-test wasn't generated", groupingContainerTest);
-        assertEquals("GroupingContainerTest interface - incorrect number of occurences", 1,
-                groupingContainerTestCounter);
-        assertEquals("GroupingContainerTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
-                groupingContainerTest.getPackageName());
+        assertNotNull(groupingContainerTest, "Generated type for grouping-container-test wasn't generated");
+        assertEquals(1, groupingContainerTestCounter,
+            "GroupingContainerTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
+            groupingContainerTest.getPackageName(), "GroupingContainerTest isn't in correct package");
 
-        assertNotNull("Generated type for container-test wasn't generated", containerTest);
-        assertEquals("ContainerTest interface - incorrect number of occurences", 1, containerTestCount);
-        assertEquals("ContainerTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718", containerTest.getPackageName());
+        assertNotNull(containerTest, "Generated type for container-test wasn't generated");
+        assertEquals(1, containerTestCount, "ContainerTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
+            containerTest.getPackageName(), "ContainerTest isn't in correct package");
 
         containsInterface("GroupingContainerTest", containerTest);
 
-        assertEquals("Number of method in GroupingContainerTestis incorrect", 4, groupingContainerTest
-                .getMethodDefinitions().size());
+        assertEquals(4, groupingContainerTest.getMethodDefinitions().size(),
+            "Number of method in GroupingContainerTestis incorrect");
         // FIXME: split this into getter/default/static asserts
         assertEquals(6, containerTest.getMethodDefinitions().size());
 
@@ -165,8 +163,8 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInGroupingTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void usesInGroupingTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/uses-of-grouping/uses-of-grouping-grouping.yang"));
 
         int groupingTestCount = 0;
@@ -174,7 +172,7 @@ public class UsesTest {
         GeneratedType groupingTest = null;
         GeneratedType groupingGroupingTest = null;
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("GroupingGroupingTest")) {
                     groupingGroupingTest = genType;
@@ -186,22 +184,21 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for grouping-grouping-test wasn't generated", groupingGroupingTest);
-        assertEquals("GroupingGroupingTest interface - incorrect number of occurences", 1, groupingGroupingTestCounter);
-        assertEquals("GroupingGroupingTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718",
-                groupingGroupingTest.getPackageName());
+        assertNotNull(groupingGroupingTest, "Generated type for grouping-grouping-test wasn't generated");
+        assertEquals(1, groupingGroupingTestCounter, "GroupingGroupingTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718",
+            groupingGroupingTest.getPackageName(), "GroupingGroupingTest isn't in correct package");
 
-        assertNotNull("Generated type for grouping-test wasn't generated", groupingTest);
-        assertEquals("GroupingTest interface - incorrect number of occurences", 1, groupingTestCount);
-        assertEquals("GroupingTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718", groupingTest.getPackageName());
+        assertNotNull(groupingTest, "Generated type for grouping-test wasn't generated");
+        assertEquals(1, groupingTestCount, "GroupingTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718", groupingTest.getPackageName(),
+            "GroupingTest isn't in correct package");
 
         containsInterface("GroupingGroupingTest", groupingTest);
 
-        assertEquals("Number of method in GroupingGroupingTest is incorrect", 2, groupingGroupingTest
-                .getMethodDefinitions().size());
-        assertEquals("Number of method in GroupingTest is incorrect", 2, groupingTest.getMethodDefinitions().size());
+        assertEquals(2, groupingGroupingTest.getMethodDefinitions().size(),
+            "Number of method in GroupingGroupingTest is incorrect");
+        assertEquals(2, groupingTest.getMethodDefinitions().size(), "Number of method in GroupingTest is incorrect");
 
         containsMethods(groupingGroupingTest.getMethodDefinitions(),
             new NameTypePattern("getLeafGroupingGrouping", "String"),
@@ -213,8 +210,8 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInListTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void usesInListTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/uses-of-grouping/uses-of-grouping-list.yang"));
 
         int listTestCounter = 0;
@@ -226,7 +223,7 @@ public class UsesTest {
         GeneratedType containerGroupingListTest = null;
         GeneratedType listGroupingListTest = null;
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("GroupingListTest")) {
                     groupingListTest = genType;
@@ -244,33 +241,31 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for grouping-list-test wasn't generated", groupingListTest);
-        assertEquals("GroupingListTest interface - incorrect number of occurences", 1, groupingListTestCounter);
-        assertEquals("GroupingListTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", groupingListTest.getPackageName());
-
-        assertNotNull("Generated type for list-test wasn't generated", listTest);
-        assertEquals("ListTest interface - incorrect number of occurences", 1, listTestCounter);
-        assertEquals("ListTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", listTest.getPackageName());
-
-        assertNotNull("Generated type for container-grouping-list-test wasn't generated", containerGroupingListTest);
-        assertEquals("ContainerGroupingListTest interface - incorrect number of occurences", 1,
-                containerGroupingListTestCounter);
-        assertEquals("ContainerGroupingListTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
-                containerGroupingListTest.getPackageName());
-
-        assertNotNull("Generated type for list-grouping-list-test wasn't generated", listGroupingListTest);
-        assertEquals("ListGroupingListTest interface - incorrect number of occurences", 1, listGroupingListTestCounter);
-        assertEquals("ListGroupingListTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
-                listGroupingListTest.getPackageName());
+        assertNotNull(groupingListTest, "Generated type for grouping-list-test wasn't generated");
+        assertEquals(1, groupingListTestCounter, "GroupingListTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", groupingListTest.getPackageName(),
+            "GroupingListTest isn't in correct package");
+
+        assertNotNull(listTest, "Generated type for list-test wasn't generated");
+        assertEquals(1, listTestCounter, "ListTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", listTest.getPackageName(),
+            "ListTest isn't in correct package");
+
+        assertNotNull(containerGroupingListTest, "Generated type for container-grouping-list-test wasn't generated");
+        assertEquals(1, containerGroupingListTestCounter,
+            "ContainerGroupingListTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
+            containerGroupingListTest.getPackageName(), "ContainerGroupingListTest isn't in correct package");
+
+        assertNotNull(listGroupingListTest, "Generated type for list-grouping-list-test wasn't generated");
+        assertEquals(1, listGroupingListTestCounter, "ListGroupingListTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
+            listGroupingListTest.getPackageName(), "ListGroupingListTest isn't in correct package");
 
         containsInterface("GroupingListTest", listTest);
 
-        assertEquals("Number of method in GroupingListTest is incorrect", 8, groupingListTest.getMethodDefinitions()
-                .size());
+        assertEquals(8, groupingListTest.getMethodDefinitions().size(),
+            "Number of method in GroupingListTest is incorrect");
         // FIXME: split this into getter/default/static asserts
         assertEquals(6, listTest.getMethodDefinitions().size());
         // FIXME: split this into getter/default/static asserts
@@ -293,8 +288,8 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInModulTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void usesInModulTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/uses-of-grouping/uses-of-grouping-modul.yang"));
 
         int groupingModulTestCounter = 0;
@@ -302,7 +297,7 @@ public class UsesTest {
         GeneratedType groupingModulTest = null;
         GeneratedType groupingUsesModulData = null;
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("GroupingModulTest")) {
                     groupingModulTest = genType;
@@ -314,24 +309,23 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for grouping-list-test wasn't generated", groupingModulTest);
-        assertEquals("GroupingModulTest interface - incorrect number of occurences", 1, groupingModulTestCounter);
-        assertEquals("GroupingModulTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718", groupingModulTest.getPackageName());
+        assertNotNull(groupingModulTest, "Generated type for grouping-list-test wasn't generated");
+        assertEquals(1, groupingModulTestCounter, "GroupingModulTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
+            groupingModulTest.getPackageName(), "GroupingModulTest isn't in correct package");
 
-        assertNotNull("Generated type for modul wasn't generated", groupingUsesModulData);
-        assertEquals("GroupingUsesModulData interface - incorrect number of occurences", 1,
-                groupingUsesModulDataCounter);
-        assertEquals("GroupingUsesModulData isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
-                groupingUsesModulData.getPackageName());
+        assertNotNull(groupingUsesModulData, "Generated type for modul wasn't generated");
+        assertEquals(1, groupingUsesModulDataCounter,
+            "GroupingUsesModulData interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
+            groupingUsesModulData.getPackageName(), "GroupingUsesModulData isn't in correct package");
 
         containsInterface("GroupingModulTest", groupingUsesModulData);
 
-        assertEquals("Number of method in GroupingUsesModulData is incorrect", 1, groupingUsesModulData
-                .getMethodDefinitions().size());
-        assertEquals("Number of method in GroupingModulTest is incorrect", 4, groupingModulTest.getMethodDefinitions()
-                .size());
+        assertEquals(1, groupingUsesModulData.getMethodDefinitions().size(),
+            "Number of method in GroupingUsesModulData is incorrect");
+        assertEquals(4, groupingModulTest.getMethodDefinitions().size(),
+            "Number of method in GroupingModulTest is incorrect");
 
         containsMethods(groupingModulTest.getMethodDefinitions(),
             new NameTypePattern("getLeafGroupingModulTest", "String"),
@@ -341,8 +335,8 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInRpcTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
+    void usesInRpcTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangResource(
                 "/uses-of-grouping/uses-of-grouping-rpc.yang"));
 
         int rpcTestInputCounter = 0;
@@ -356,7 +350,7 @@ public class UsesTest {
         GeneratedType groupingRpcOutputTest = null;
         GeneratedType containerGroupingRpcInputTest = null;
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("RpcTestInput")) {
                     rpcTestInput = genType;
@@ -378,33 +372,32 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for RPC test input was not generated", rpcTestInput);
-        assertEquals("RpcTestInput interface - incorrect number of occurences", 1, rpcTestInputCounter);
-        assertEquals("RpcTestInput is not in correct package",
-            "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName());
-
-        assertNotNull("Generated type for RPC test output was not generated", rpcTestOutput);
-        assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, rpcTestOutputCounter);
-        assertEquals("RpcTestOutput is not in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName());
-
-        assertNotNull("Generated type for grouping-rpc-input-test was not generated", groupingRpcInputTest);
-        assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcInputTestCounter);
-        assertEquals("GroupingRpcInputTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcInputTest.getPackageName());
-
-        assertNotNull("Generated type for grouping-rpc-output-test was not generated", groupingRpcOutputTest);
-        assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcOutputTestCounter);
-        assertEquals("GroupingRpcOutputTest isn't in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcOutputTest.getPackageName());
-
-        assertNotNull("Generated type for container-grouping-rpc-input-test wasn't generated",
-                containerGroupingRpcInputTest);
-        assertEquals("ContainerGroupingRpcInputTest interface - incorrect number of occurences", 1,
-                containerGroupingRpcInputTestCounter);
-        assertEquals("ContainerGroupingRpcInputTest is not in correct package",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
-                containerGroupingRpcInputTest.getPackageName());
+        assertNotNull(rpcTestInput, "Generated type for RPC test input was not generated");
+        assertEquals(1, rpcTestInputCounter, "RpcTestInput interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName(),
+            "RpcTestInput is not in correct package");
+
+        assertNotNull(rpcTestOutput, "Generated type for RPC test output was not generated");
+        assertEquals(1, rpcTestOutputCounter, "RpcTestOutput interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName(),
+            "RpcTestOutput is not in correct package");
+
+        assertNotNull(groupingRpcInputTest, "Generated type for grouping-rpc-input-test was not generated");
+        assertEquals(1, groupingRpcInputTestCounter, "RpcTestOutput interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718",
+            groupingRpcInputTest.getPackageName(), "GroupingRpcInputTest isn't in correct package");
+
+        assertNotNull(groupingRpcOutputTest, "Generated type for grouping-rpc-output-test was not generated");
+        assertEquals(1, groupingRpcOutputTestCounter, "RpcTestOutput interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718",
+            groupingRpcOutputTest.getPackageName(), "GroupingRpcOutputTest isn't in correct package");
+
+        assertNotNull(containerGroupingRpcInputTest,
+            "Generated type for container-grouping-rpc-input-test wasn't generated");
+        assertEquals(1, containerGroupingRpcInputTestCounter,
+            "ContainerGroupingRpcInputTest interface - incorrect number of occurences");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
+            containerGroupingRpcInputTest.getPackageName(), "ContainerGroupingRpcInputTest is not in correct package");
 
         containsInterface("GroupingRpcInputTest", rpcTestInput);
         containsInterface("GroupingRpcOutputTest", rpcTestOutput);
@@ -413,10 +406,10 @@ public class UsesTest {
         assertEquals(4, rpcTestInput.getMethodDefinitions().size());
         // FIXME: split this into getter/default/static asserts
         assertEquals(4, rpcTestOutput.getMethodDefinitions().size());
-        assertEquals("Number of method in GroupingRpcInputTest is incorrect", 4, groupingRpcInputTest
-                .getMethodDefinitions().size());
-        assertEquals("Number of method in GroupingRpcOutputTest is incorrect", 2, groupingRpcOutputTest
-                .getMethodDefinitions().size());
+        assertEquals(4, groupingRpcInputTest.getMethodDefinitions().size(),
+            "Number of method in GroupingRpcInputTest is incorrect");
+        assertEquals(2, groupingRpcOutputTest.getMethodDefinitions().size(),
+            "Number of method in GroupingRpcOutputTest is incorrect");
         // FIXME: split this into getter/default/static asserts
         assertEquals(6, containerGroupingRpcInputTest.getMethodDefinitions().size());
 
@@ -431,8 +424,8 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInAugmentTest() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+    void usesInAugmentTest() {
+        final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-augment.yang"));
 
         GeneratedType containerAugment1 = null;
@@ -440,7 +433,7 @@ public class UsesTest {
         int containerAugment1Counter = 0;
         int groupingAugmentTestCounter = 0;
 
-        for (GeneratedType genType : genTypes) {
+        for (var genType : genTypes) {
             if (!(genType instanceof GeneratedTransferObject)) {
                 if (genType.getName().equals("ContainerAugment1")) {
                     containerAugment1 = genType;
@@ -452,16 +445,15 @@ public class UsesTest {
             }
         }
 
-        assertNotNull("Generated type for augment /container-augment wasn't generated.", containerAugment1);
-        assertEquals("ContainerAugment1 interface generated more than one time.", 1, containerAugment1Counter);
-        assertEquals("ContainerAugment1 is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718", containerAugment1.getPackageName());
+        assertNotNull(containerAugment1, "Generated type for augment /container-augment wasn't generated.");
+        assertEquals(1, containerAugment1Counter, "ContainerAugment1 interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
+            containerAugment1.getPackageName(), "ContainerAugment1 is in wrong package.");
 
-        assertNotNull("Generated type for grouping-augment-test wasn't generated.", groupingAugmentTest);
-        assertEquals("GroupingAugmentTest interface generated more than one time.", 1, groupingAugmentTestCounter);
-        assertEquals("groupingAugmentTest is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
-                groupingAugmentTest.getPackageName());
+        assertNotNull(groupingAugmentTest, "Generated type for grouping-augment-test wasn't generated.");
+        assertEquals(1, groupingAugmentTestCounter, "GroupingAugmentTest interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
+            groupingAugmentTest.getPackageName(), "groupingAugmentTest is in wrong package.");
 
         containsInterface("GroupingAugmentTest", containerAugment1);
 
@@ -469,8 +461,8 @@ public class UsesTest {
         assertEquals(4, containerAugment1.getMethodDefinitions().size());
         // FIXME: split this into getter/default/static asserts
         assertEquals(4, containerAugment1.getMethodDefinitions().size());
-        assertEquals("Number of method in GroupingCaseTest is incorrect", 2, groupingAugmentTest.getMethodDefinitions()
-                .size());
+        assertEquals(2, groupingAugmentTest.getMethodDefinitions().size(),
+            "Number of method in GroupingCaseTest is incorrect");
 
         containsMethods(groupingAugmentTest.getMethodDefinitions(),
             new NameTypePattern("getLeafGroupingAugmentTest", "String"),
@@ -478,8 +470,8 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInNotification() {
-        final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
+    void usesInNotification() {
+        final var genTypes = DefaultBindingGenerator.generateFor(
             YangParserTestUtils.parseYangResource("/uses-of-grouping/uses-of-grouping-notification.yang"));
 
         GeneratedType notificationTest = null;
@@ -489,49 +481,46 @@ public class UsesTest {
         int groupingNotificationTestCounter = 0;
         int containerGroupingNotificationTestCounter = 0;
 
-        for (GeneratedType type : genTypes) {
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
-                GeneratedType genType = type;
-                if (genType.getName().equals("NotificationTest")) {
-                    notificationTest = genType;
+        for (var type : genTypes) {
+            if (!(type instanceof GeneratedTransferObject)) {
+                if (type.getName().equals("NotificationTest")) {
+                    notificationTest = type;
                     notificationTestCounter++;
-                } else if (genType.getName().equals("GroupingNotificationTest")) {
-                    groupingNotificationTest = genType;
+                } else if (type.getName().equals("GroupingNotificationTest")) {
+                    groupingNotificationTest = type;
                     groupingNotificationTestCounter++;
-                } else if (genType.getName().equals("ContainerGroupingNotificationTest")) {
-                    containerGroupingNotificationTest = genType;
+                } else if (type.getName().equals("ContainerGroupingNotificationTest")) {
+                    containerGroupingNotificationTest = type;
                     containerGroupingNotificationTestCounter++;
                 }
             }
         }
 
-        assertNotNull("Generated type for notification-test wasn't generated.", notificationTest);
-        assertEquals("NotificationTest interface generated more than one time.", 1, notificationTestCounter);
-        assertEquals("NotificationTest is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
-                notificationTest.getPackageName());
-
-        assertNotNull("Generated type for grouping-notification-test wasn't generated.", groupingNotificationTest);
-        assertEquals("GroupingNotificationTest interface generated more than one time.", 1,
-                groupingNotificationTestCounter);
-        assertEquals("groupingNotificationTest is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
-                groupingNotificationTest.getPackageName());
-
-        assertNotNull("Generated type for container-grouping-notification-test wasn't generated.",
-                containerGroupingNotificationTest);
-        assertEquals("ContainerGroupingNotificationTest interface generated more than one time.", 1,
-                containerGroupingNotificationTestCounter);
-        assertEquals("ContainerGroupingNotificationTest is in wrong package.",
-                "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718.grouping.notification.test",
-                containerGroupingNotificationTest.getPackageName());
+        assertNotNull(notificationTest, "Generated type for notification-test wasn't generated.");
+        assertEquals(1, notificationTestCounter, "NotificationTest interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
+            notificationTest.getPackageName(), "NotificationTest is in wrong package.");
+
+        assertNotNull(groupingNotificationTest, "Generated type for grouping-notification-test wasn't generated.");
+        assertEquals(1, groupingNotificationTestCounter,
+            "GroupingNotificationTest interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
+            groupingNotificationTest.getPackageName(), "groupingNotificationTest is in wrong package.");
+
+        assertNotNull(containerGroupingNotificationTest,
+            "Generated type for container-grouping-notification-test wasn't generated.");
+        assertEquals(1, containerGroupingNotificationTestCounter,
+            "ContainerGroupingNotificationTest interface generated more than one time.");
+        assertEquals("org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718.grouping.notification.test",
+            containerGroupingNotificationTest.getPackageName(),
+            "ContainerGroupingNotificationTest is in wrong package.");
 
         containsInterface("GroupingNotificationTest", notificationTest);
 
         // FIXME: split this into getter/default/static asserts
         assertEquals(6, notificationTest.getMethodDefinitions().size());
-        assertEquals("Number of method in GroupingNotificationTest is incorrect", 4, groupingNotificationTest
-                .getMethodDefinitions().size());
+        assertEquals(4, groupingNotificationTest.getMethodDefinitions().size(),
+            "Number of method in GroupingNotificationTest is incorrect");
         // FIXME: split this into getter/default/static asserts
         assertEquals(6, containerGroupingNotificationTest.getMethodDefinitions().size());
 
@@ -545,5 +534,4 @@ public class UsesTest {
             new NameTypePattern("getLeafContainerGroupingNotificationTest", "Uint32"),
             new NameTypePattern("requireLeafContainerGroupingNotificationTest", "Uint32"));
     }
-
 }
index b491e60ce3a39d0093e373d65b784b835472ab5a..45ba0a4b98e16008bcd142494eed03056fe41e83 100644 (file)
@@ -7,56 +7,55 @@
  */
 package org.opendaylight.yangtools.binding.generator.impl.reactor;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.doReturn;
 
 import java.util.List;
 import java.util.Optional;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.yangtools.binding.model.api.GeneratedTransferObject;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.yangtools.binding.model.api.JavaTypeName;
 import org.opendaylight.yangtools.binding.model.api.type.builder.GeneratedTOBuilder;
 import org.opendaylight.yangtools.binding.model.ri.generated.type.builder.CodegenGeneratedTOBuilder;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class GeneratorTest {
+@ExtendWith(MockitoExtension.class)
+class GeneratorTest {
     @Mock
-    public TypeDefinition<?> typedef;
+    private TypeDefinition<?> typedef;
 
-    public final GeneratedTOBuilder builder =
+    private final GeneratedTOBuilder builder =
         new CodegenGeneratedTOBuilder(JavaTypeName.create("test.package", "TestBuilder"));
 
     @Test
-    public void testAddUnits() {
+    void testAddUnits() {
         doReturn(Optional.of("125")).when(typedef).getUnits();
 
         Generator.addUnits(builder, typedef);
-        final GeneratedTransferObject genTO = builder.build();
+        final var genTO = builder.build();
         assertEquals(1, genTO.getConstantDefinitions().size());
         assertEquals("_UNITS", genTO.getConstantDefinitions().get(0).getName());
         assertEquals(genTO.getConstantDefinitions().get(0).getValue(), "\"125\"");
     }
 
     @Test
-    public void testAddUnitsNonExistent() {
+    void testAddUnitsNonExistent() {
         doReturn(Optional.empty()).when(typedef).getUnits();
 
         Generator.addUnits(builder, typedef);
-        GeneratedTransferObject genTO = builder.build();
+        var genTO = builder.build();
         assertEquals(List.of(), genTO.getConstantDefinitions());
 
     }
 
     @Test
-    public void testAddUnitsEmpty() {
+    void testAddUnitsEmpty() {
         doReturn(Optional.of("")).when(typedef).getUnits();
 
         Generator.addUnits(builder, typedef);
-        GeneratedTransferObject genTO = builder.build();
+        var genTO = builder.build();
         assertEquals(List.of(), genTO.getConstantDefinitions());
     }
 }