forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from iamdiluxedbutcooler/add-close-split-command
Add close command
- Loading branch information
Showing
8 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/seedu/address/logic/commands/CloseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandCommons.EMPTY_PERSON; | ||
|
||
import seedu.address.model.Model; | ||
|
||
/** | ||
* Closes the detail view in the address book. | ||
*/ | ||
public class CloseCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "close"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Detailed view closed."; | ||
|
||
@Override | ||
public CommandResult execute(Model model) { | ||
return new CommandResult( | ||
MESSAGE_SUCCESS, | ||
false, | ||
false, | ||
false, | ||
EMPTY_PERSON, | ||
false | ||
); | ||
} | ||
@Override | ||
public boolean equals(Object obj) { | ||
return obj == this || obj instanceof CloseCommand; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return COMMAND_WORD; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/seedu/address/logic/commands/CommandCommons.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* Contains common values used in different command classes, including default command values. | ||
*/ | ||
public final class CommandCommons { | ||
public static final String DEFAULT_TIER = ""; | ||
public static final String DEFAULT_REMARK = "NA"; | ||
public static final Person EMPTY_PERSON = null; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/seedu/address/logic/commands/CloseCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
|
||
public class CloseCommandTest { | ||
|
||
private Model model = new ModelManager(); | ||
@Test | ||
public void execute_close_success() { | ||
CloseCommand closeCommand = new CloseCommand(); | ||
CommandResult commandResult = closeCommand.execute(model); | ||
|
||
assertEquals(CloseCommand.MESSAGE_SUCCESS, commandResult.getFeedbackToUser()); | ||
assertFalse(commandResult.isShowHelp()); | ||
assertFalse(commandResult.isExit()); | ||
} | ||
|
||
@Test | ||
public void equals() { | ||
CloseCommand closeCommand = new CloseCommand(); | ||
|
||
// same object -> returns true | ||
assertTrue(closeCommand.equals(closeCommand)); | ||
|
||
// same type -> returns true | ||
assertTrue(closeCommand.equals(new CloseCommand())); | ||
|
||
// null -> returns false | ||
assertFalse(closeCommand.equals(null)); | ||
|
||
// different types -> returns false | ||
assertFalse(closeCommand.equals(1)); | ||
} | ||
|
||
@Test | ||
public void toStringMethod() { | ||
CloseCommand closeCommand = new CloseCommand(); | ||
assertEquals(CloseCommand.COMMAND_WORD, closeCommand.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters