package seedu.address.testutil;

/**
 * A set of assertion methods useful for writing tests.
 */
public class Assert {

    /**
     * Asserts that the {@code callable} throws the {@code expected} Exception.
     */
    public static void assertThrows(Class<? extends Throwable> expected, VoidCallable callable) {
        assertThrows(expected, null, callable);
    }

    /**
     * Asserts that the {@code callable} throws the {@code expectedException} and the {@code expectedMessage}.
     * If there's no need for the verification of the exception's error message, call
     * {@code assertThrows(Class<? extends Throwable>, VoidCallable)} instead.
     * {@see assertThrows(Class<? extends Throwable>, VoidCallable}
     */
    public static void assertThrows(Class<? extends Throwable> expectedException, String expectedMessage,
                                    VoidCallable callable) {
        try {
            callable.call();
        } catch (Throwable actualException) {
            String errorMessage;

            if (!actualException.getClass().isAssignableFrom(expectedException)) {
                errorMessage = String.format("Expected exception thrown: %s, actual: %s",
                        expectedException.getName(), actualException.getClass().getName());
            } else if (expectedMessage != null && !expectedMessage.equals(actualException.getMessage())) {
                errorMessage = String.format(
                        "Expected message thrown: %s, actual: %s", expectedMessage, actualException.getMessage());
            } else {
                return;
            }

            throw new AssertionError(errorMessage, actualException);
        }

        throw new AssertionError(String.format(
                "Expected %s to be thrown, but nothing was thrown.", expectedException.getName()));
    }

    /**
     * Represents a function which does not return anything and may throw an exception.
     */
    @FunctionalInterface
    public interface VoidCallable {
        void call() throws Exception;
    }

}

@@ -26,16 +26,108 @@
 tutil;%0A%0A
+import org.junit.jupiter.api.Assertions;%0Aimport org.junit.jupiter.api.function.Executable;%0A%0A
 /**%0A * A
@@ -236,36 +236,38 @@
 that the %7B@code 
-call
+execut
 able%7D throws the
@@ -282,16 +282,20 @@
 expected
+Type
 %7D Except
@@ -291,32 +291,381 @@
 ype%7D Exception.%0A
+     * This is a wrapper method that invokes %7B@link Assertions#assertThrows(Class, Executable)%7D, to maintain consistency%0A     * with our custom %7B@link #assertThrows(Class, String, Executable)%7D method.%0A     * To standardize API calls in this project, users should use this method instead of%0A     * %7B@link Assertions#assertThrows(Class, Executable)%7D.%0A
      */%0A    publ
@@ -731,27 +731,31 @@
 cted
-, VoidCallable call
+Type, Executable execut
 able
@@ -766,16 +766,27 @@
         
+Assertions.
 assertTh
@@ -802,20 +802,20 @@
 cted
-, null, call
+Type, execut
 able
@@ -863,20 +863,22 @@
  %7B@code 
-call
+execut
 able%7D th
@@ -893,32 +893,38 @@
  %7B@code expected
+Type%7D 
 Exception%7D and t
@@ -920,13 +920,13 @@
 tion
-%7D and
+ with
  the
@@ -1046,21 +1046,22 @@
     * %7B@
-code 
+link #
 assertTh
@@ -1074,39 +1074,16 @@
 lass
-%3C? extends Throwable%3E, VoidCall
+, Execut
 able
@@ -1104,15 +1104,22 @@
    *
+%0A     *
  
-%7B
 @see 
+#
 asse
@@ -1136,44 +1136,21 @@
 lass
-%3C? extends Throwable%3E, VoidCall
+, Execut
 able
-%7D
+)
 %0A   
@@ -1225,25 +1225,20 @@
 expected
-Exception
+Type
 , String
@@ -1271,117 +1271,41 @@
     
-                        VoidCallable callable) %7B%0A        try %7B%0A            callable.call();%0A        %7D catch (
+Executable executable) %7B%0A        
 Thro
@@ -1310,22 +1310,22 @@
 rowable 
-actual
+thrown
 Exceptio
@@ -1329,1082 +1329,147 @@
 tion
-) %7B%0A            String errorMessage;%0A%0A            if (!actualException.getClass().isAssignableFrom(expectedException)) %7B%0A                errorMessage = String.format(%22Expected exception thrown: %25s, actual: %25s%22,%0A                        expectedException.getName(), actualException.getClass().getName());%0A            %7D else if (
+ = Assertions.assertThrows(expectedType, 
 ex
-p
 ec
-tedMessage != null && !expectedMessage.equals(actualException.getMessage())) %7B%0A                errorMessage = String.format(%0A                        %22Expected message thrown: %25s, actual: %25s%22, expectedMessage, actualException.getMessage());%0A            %7D else %7B%0A                return;%0A            %7D%0A%0A            throw new AssertionError(errorMessage, actualException);%0A        %7D%0A%0A        throw new AssertionError(String.format(%0A                %22Expected %25s to be thrown, but nothing was thrown.%22, expectedException.getName()));%0A    %7D%0A%0A    /**%0A     * Represents a function which does not return anything and may throw an exception.%0A     */%0A    @FunctionalInterface%0A    public interface VoidCallable %7B%0A        void call() throws Exception
+utable);%0A        Assertions.assertEquals(expectedMessage, thrownException.getMessage())
 ;%0A    %7D%0A
 %0A%7D%0A
@@ -1465,11 +1465,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Use JUnit 5 Assert#assertThrows