package seedu.address.logic.commands;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static seedu.address.logic.commands.ExitCommand.MESSAGE_EXIT_ACKNOWLEDGEMENT;

import org.junit.Before;
import org.junit.Test;

import com.google.common.eventbus.Subscribe;

import seedu.address.commons.core.EventsCenter;
import seedu.address.commons.events.ui.ExitAppRequestEvent;

public class ExitCommandTest {
    private boolean isEventCaught = false;

    @Subscribe
    private void handleExitAppRequestEvent(ExitAppRequestEvent eare) {
        isEventCaught = true;
    }

    @Before
    public void setUp() {
        EventsCenter.getInstance().registerHandler(this);
    }

    @Test
    public void execute_exit_success() {
        CommandResult result = new ExitCommand().execute();
        assertEquals(MESSAGE_EXIT_ACKNOWLEDGEMENT, result.feedbackToUser);
        assertTrue(isEventCaught);
    }
}

@@ -227,132 +227,73 @@
 nit.
-Before;%0Aimport org.junit.Test;%0A%0Aimport com.google.common.eventbus.Subscribe;%0A%0Aimport seedu.address.commons.core.EventsC
+Test;%0A%0Aimport seedu.address.commons.events.ui.ExitAppRequestEv
 ent
-er
 ;%0Aim
@@ -315,45 +315,32 @@
 ess.
-commons.events.ui.ExitAppRequestEvent
+testutil.EventsCollector
 ;%0A%0Ap
@@ -373,134 +373,56 @@
 t %7B%0A
+%0A
     
-private boolean isEventCaught = false;%0A%0A    @Subscribe%0A    private void handleExitAppRequestEvent(ExitAppRequestEvent eare
+@Test%0A    public void execute_exit_success(
 ) %7B%0A
@@ -433,190 +433,64 @@
     
-is
 Event
-Caught = true;%0A    %7D%0A%0A    @Before%0A    public void setUp() %7B%0A        EventsCenter.getInstance().registerHandler(this);%0A    %7D%0A%0A    @Test%0A    public void execute_exit_success() %7B
+sCollector eventCollector = new EventsCollector();%0A
 %0A   
@@ -644,21 +644,120 @@
 rue(
-isEventCaught
+eventCollector.getMostRecent() instanceof ExitAppRequestEvent);%0A        assertTrue(eventCollector.getSize() == 1
 );%0A 

Use EventsCollector to receive events