Skip to content

Commit

Permalink
Merge pull request #5 from AY1920S1-CS2103T-F12-2/master
Browse files Browse the repository at this point in the history
chore: sync with team repo
  • Loading branch information
Q-gabe authored Oct 13, 2019
2 parents 3f43fff + df466ce commit cb9c0ea
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Changes the visitList of an existing person in the address book.
*/
public class AddVisitCommand extends Command {
public static final String COMMAND_WORD = "addVisit";
public static final String COMMAND_WORD = "addvisit";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Add the visitation record of the person identified "
+ "by the index number used in the last person listing. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Deletes record of patient by index.
*/
public class DeleteVisitCommand extends Command {
public static final String COMMAND_WORD = "deleteVisit";
public static final String COMMAND_WORD = "deletevisit";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the visitation record of the person identified "
Expand All @@ -27,6 +27,7 @@ public class DeleteVisitCommand extends Command {
+ PREFIX_DELETE_VISIT + "2";

public static final String MESSAGE_DELETE_VISIT_SUCCESS = "Removed visit from Person: %1$s";
public static final String MESSAGE_MISSING_INDEX_PROMPT = "Please specify index of report to be deleted";

private final Index index;
private final int id;
Expand Down Expand Up @@ -62,6 +63,8 @@ public CommandResult execute(Model model) throws CommandException {
} catch (IndexOutOfBoundsException e) {
throw new CommandException(Messages.MESSAGE_INVALID_REPORT_INDEX);
}
} else {
return new CommandResult(MESSAGE_MISSING_INDEX_PROMPT, editedPerson.getVisitList().getObservableRecords());
}
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public boolean equals(Object other) {
return index.equals(e.index)
&& medication.equals(e.medication)
&& diagnosis.equals(e.diagnosis)
&& remarks.equals(e.remarks);
&& remarks.equals(e.remarks)
&& visitReport.date.equals(e.visitReport.date);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public Command parseCommand(String userInput) throws ParseException {
final String commandWord = matcher.group("commandWord");
final String arguments = matcher.group("arguments");

switch (commandWord) {
switch (commandWord.toLowerCase()) {

case AliasCommand.COMMAND_WORD:
return new AliasCommandParser().parse(arguments);
Expand All @@ -75,7 +75,6 @@ public Command parseCommand(String userInput) throws ParseException {
return new AddVisitCommandParser().parse(arguments);

case DeleteVisitCommand.COMMAND_WORD:
System.out.println(commandWord);
return new DeleteVisitCommandParser().parse(arguments);

case ProfileCommand.COMMAND_WORD:
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/seedu/address/logic/commands/CommandResultTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,20 @@ public void hashcode() {
// different date value -> returns different hashcode
assertNotEquals(commandResult.hashCode(), new CommandResult("feedback", 0, "false").hashCode());
}

@Test
public void getters() {
CommandResult commandResult = new CommandResult("feedback", false, false, false, false);

assertEquals(commandResult.isAddVisit(), false);
assertEquals(commandResult.isDeleteVisit(), false);
assertEquals(commandResult.isExit(), false);
assertEquals(commandResult.isShowHelp(), false);

CommandResult commandResult2 = new CommandResult("feedback", 3, "12/12/2012");

assertEquals(commandResult2.getIdx(), 3);
assertEquals(commandResult2.getDate(), "12/12/2012");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

Expand Down Expand Up @@ -34,4 +37,29 @@ public void execute_deleteVisitCommandUnfilteredList_success() {

assertCommandSuccess(deleteVisitCommand, model, expectedMessage, expectedModel);
}

@Test
public void equals() {
DeleteVisitCommand deleteFirstCommand = new DeleteVisitCommand(INDEX_FIRST_PERSON, 1);
DeleteVisitCommand deleteSecondCommand = new DeleteVisitCommand(INDEX_SECOND_PERSON, 1);

// same object -> returns true
assertTrue(deleteFirstCommand.equals(deleteFirstCommand));

// same values -> returns true
DeleteVisitCommand deleteFirstCommandCopy = new DeleteVisitCommand(INDEX_FIRST_PERSON, 1);
assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy));

DeleteCommand deleteFirstCommandNoIndex = new DeleteCommand(INDEX_FIRST_PERSON);
assertFalse(deleteFirstCommand.equals(deleteFirstCommandNoIndex));

// different types -> returns false
assertFalse(deleteFirstCommand.equals(1));

// null -> returns false
assertFalse(deleteFirstCommand.equals(null));

// different person -> returns false
assertFalse(deleteFirstCommand.equals(deleteSecondCommand));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
Expand Down Expand Up @@ -67,4 +68,49 @@ public void execute_invalidPersonIndexFilteredList_failure() {
assertCommandFailure(saveVisitCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

@Test
public void equals() {

SaveVisitCommand saveVisitCommand =
new SaveVisitCommand(1, "12/12/2012", "meds", "diagnosis", "remarks");

// same object -> returns true
assertTrue(saveVisitCommand.equals(saveVisitCommand));

// same values -> returns true
SaveVisitCommand saveVisitCommand2 =
new SaveVisitCommand(1, "12/12/2012", "meds", "diagnosis", "remarks");

assertTrue(saveVisitCommand.equals(saveVisitCommand2));

// different types -> returns false
assertFalse(saveVisitCommand.equals(1));

// null -> returns false
assertFalse(saveVisitCommand2.equals(null));

// different idx -> returns false
SaveVisitCommand saveVisitCommandIdx =
new SaveVisitCommand(2, "12/12/2012", "meds", "diagnosis", "remarks");
assertFalse(saveVisitCommand2.equals(saveVisitCommandIdx));

SaveVisitCommand saveVisitCommandDate =
new SaveVisitCommand(1, "13/12/2012", "meds", "diagnosis", "remarks");
assertFalse(saveVisitCommand2.equals(saveVisitCommandDate));

SaveVisitCommand saveVisitCommandMeds =
new SaveVisitCommand(1, "12/12/2012", "medicine", "diagnosis", "remarks");
assertFalse(saveVisitCommand2.equals(saveVisitCommandMeds));

SaveVisitCommand saveVisitCommandDiagnosis =
new SaveVisitCommand(1, "12/12/2012", "meds", "dg", "remarks");
assertFalse(saveVisitCommand2.equals(saveVisitCommandDiagnosis));

SaveVisitCommand saveVisitCommandRemark =
new SaveVisitCommand(1, "12/12/2012", "meds", "dg", "rm");

assertFalse(saveVisitCommand2.equals(saveVisitCommandRemark));

}

}

0 comments on commit cb9c0ea

Please sign in to comment.