Migrate rfc8639-parser-support to JUnit5 07/106907/7
authormatus.matok <matus.matok@pantheon.tech>
Thu, 13 Jul 2023 08:38:19 +0000 (10:38 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 17 Oct 2023 08:32:27 +0000 (08:32 +0000)
Migrated all tests to use JUnit5 Assertions, using
openrewrite:rewrite-testing-frameworks.

JIRA: YANGTOOLS-1521
Change-Id: I5e3d60cca03a1b8af3b50b96ed2db542a8bb3258
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/rfc8639-parser-support/src/test/java/org/opendaylight/yangtools/rfc8639/parser/SubscribedNotificationsTest.java

index 09000fcd89d083c59ee04680036a40ea89d6cf50..ccaa5534c38ecfa7da5191a5ce6a3ae7911e762b 100644 (file)
@@ -7,44 +7,27 @@
  */
 package org.opendaylight.yangtools.rfc8639.parser;
 
-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.io.IOException;
-import java.util.stream.Collectors;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.rfc8639.model.api.SubscribedNotificationsConstants;
 import org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
-import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 
-public class SubscribedNotificationsTest {
-    private static CrossSourceStatementReactor reactor;
-
-    @BeforeClass
-    public static void createReactor() {
-        reactor = RFC7950Reactors.vanillaReactorBuilder()
+class SubscribedNotificationsTest {
+    @Test
+    void testSubscribedNotifications() throws Exception {
+        final var reactor = RFC7950Reactors.vanillaReactorBuilder()
                 .addStatementSupport(ModelProcessingPhase.FULL_DECLARATION,
-                    new SubscriptionStateNotificationStatementSupport(YangParserConfiguration.DEFAULT))
+                        new SubscriptionStateNotificationStatementSupport(YangParserConfiguration.DEFAULT))
                 .build();
-    }
 
-    @AfterClass
-    public static void freeReactor() {
-        reactor = null;
-    }
-
-    @Test
-    public void testSubscribedNotifications() throws ReactorException, IOException, YangSyntaxErrorException {
         final var context = reactor.newBuild()
             .addLibSources(
                 YangStatementStreamSource.create(YangTextSchemaSource.forResource(
@@ -70,12 +53,12 @@ public class SubscribedNotificationsTest {
 
         final var notifications = context.getModuleStatement(SubscribedNotificationsConstants.RFC8639_MODULE)
             .streamEffectiveSubstatements(NotificationEffectiveStatement.class)
-            .collect(Collectors.toUnmodifiableList());
+            .toList();
 
         assertEquals(7, notifications.size());
-        for (NotificationEffectiveStatement notif : notifications) {
+        for (var notif : notifications) {
             final var sub = notif.findFirstEffectiveSubstatement(SubscriptionStateNotificationEffectiveStatement.class);
-            assertTrue("No marker in " + notif.argument(), sub.isPresent());
+            assertTrue(sub.isPresent(), "No marker in " + notif.argument());
         }
     }
 }