package seedu.address.testutil;

import junit.framework.AssertionFailedError;

/**
 * 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) {
        try {
            callable.call();
        } catch (Throwable actualException) {
            if (actualException.getClass().isAssignableFrom(expected)) {
                return;
            }
            String message = String.format("Expected thrown: %s, actual: %s", expected.getName(),
                    actualException.getClass().getName());
            throw new AssertionFailedError(message);
        }
        throw new AssertionFailedError(
                String.format("Expected %s to be thrown, but nothing was thrown.", expected.getName()));
    }

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

}

@@ -349,24 +349,606 @@
 callable) %7B%0A
+        assertThrows(expected, null, callable);%0A    %7D%0A%0A    /**%0A     * Asserts that the %7B@code callable%7D throws the %7B@code expectedException%7D and the %7B@code expectedMessage%7D.%0A     * If there's no need for the verification of the exception's error message, call%0A     * %7B@code assertThrows(Class%3C? extends Throwable%3E, VoidCallable)%7D instead.%0A     * %7B@see assertThrows(Class%3C? extends Throwable%3E, VoidCallable%7D%0A     */%0A    public static void assertThrows(Class%3C? extends Throwable%3E expectedException, String expectedMessage,%0A                                    VoidCallable callable) %7B%0A
         try 
@@ -1020,24 +1020,58 @@
 xception) %7B%0A
+            String errorMessage;%0A%0A
             
@@ -1074,16 +1074,17 @@
     if (
+!
 actualEx
@@ -1127,16 +1127,25 @@
 expected
+Exception
 )) %7B%0A   
@@ -1161,15 +1161,81 @@
     
-return;
+errorMessage = String.format(%22Expected exception thrown: %25s, actual: %25s%22,
 %0A   
@@ -1235,34 +1235,32 @@
 s%22,%0A            
-%7D%0A
             Stri
@@ -1259,39 +1259,253 @@
     
-String message = String.format(
+expectedException.getName(), actualException.getClass().getName());%0A            %7D else if (expectedMessage != null && !expectedMessage.equals(actualException.getMessage())) %7B%0A                errorMessage = String.format(%0A                        
 %22Exp
@@ -1510,16 +1510,24 @@
 xpected 
+message 
 thrown: 
@@ -1551,27 +1551,55 @@
 expected
-.getName(),
+Message, actualException.getMessage());
 %0A       
@@ -1607,67 +1607,68 @@
     
-        actualException.getClass().getName());%0A     
+%7D else %7B%0A                return;%0A            %7D%0A%0A
        
+     
 thro
@@ -1694,17 +1694,22 @@
 edError(
-m
+errorM
 essage);
@@ -1719,16 +1719,17 @@
       %7D%0A
+%0A
         
@@ -1759,16 +1759,30 @@
 edError(
+String.format(
 %0A       
@@ -1790,30 +1790,16 @@
         
-String.format(
 %22Expecte
@@ -1851,16 +1851,25 @@
 expected
+Exception
 .getName

add overloaded method assertThrows(Class, String, VoidCallable)