Use @Serial in util
[yangtools.git] / common / util / src / test / java / org / opendaylight / yangtools / util / concurrent / ReflectiveExceptionMapperTest.java
index c18ac1ff19ddec2bab0d28d0684925104f6250de..9dda0bcb323c900a0cbae6dc824fea57a3ca1611 100644 (file)
@@ -8,21 +8,23 @@
 package org.opendaylight.yangtools.util.concurrent;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
 
+import java.io.Serial;
 import java.util.concurrent.ExecutionException;
-
 import org.junit.Test;
 
-public final class ReflectiveExceptionMapperTest {
+public class ReflectiveExceptionMapperTest {
     static final class NoArgumentCtorException extends Exception {
+        @Serial
         private static final long serialVersionUID = 1L;
 
-        public NoArgumentCtorException() {
-            super();
+        NoArgumentCtorException() {
         }
     }
 
     static final class PrivateCtorException extends Exception {
+        @Serial
         private static final long serialVersionUID = 1L;
 
         private PrivateCtorException(final String message, final Throwable cause) {
@@ -31,14 +33,16 @@ public final class ReflectiveExceptionMapperTest {
     }
 
     static final class FailingCtorException extends Exception {
+        @Serial
         private static final long serialVersionUID = 1L;
 
-        public FailingCtorException(final String message, final Throwable cause) {
+        FailingCtorException(final String message, final Throwable cause) {
             throw new IllegalArgumentException("just for test");
         }
     }
 
-    static final class GoodException extends Exception {
+    public static final class GoodException extends Exception {
+        @Serial
         private static final long serialVersionUID = 1L;
 
         public GoodException(final String message, final Throwable cause) {
@@ -47,24 +51,28 @@ public final class ReflectiveExceptionMapperTest {
     }
 
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void testNoArgumentsContructor() {
-        ReflectiveExceptionMapper.create("no arguments", NoArgumentCtorException.class);
+        assertThrows(IllegalArgumentException.class,
+            () -> ReflectiveExceptionMapper.create("no arguments", NoArgumentCtorException.class));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void testPrivateContructor() {
-        ReflectiveExceptionMapper.create("private constructor", PrivateCtorException.class);
+        assertThrows(IllegalArgumentException.class,
+            () -> ReflectiveExceptionMapper.create("private constructor", PrivateCtorException.class));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test
     public void testFailingContructor() {
-        ReflectiveExceptionMapper.create("failing constructor", FailingCtorException.class);
+        assertThrows(IllegalArgumentException.class,
+            () -> ReflectiveExceptionMapper.create("failing constructor", FailingCtorException.class));
     }
 
     @Test
     public void testInstantiation() {
-        ReflectiveExceptionMapper<GoodException> mapper = ReflectiveExceptionMapper.create("instantiation", GoodException.class);
+        ReflectiveExceptionMapper<GoodException> mapper = ReflectiveExceptionMapper.create("instantiation",
+            GoodException.class);
 
         final Throwable cause = new Throwable("some test message");