forked from nus-cs2103-AY2324S1/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.
- Loading branch information
1 parent
b60311f
commit dc5758a
Showing
13 changed files
with
446 additions
and
0 deletions.
There are no files selected for viewing
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
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
83 changes: 83 additions & 0 deletions
83
src/test/java/seedu/address/logic/parser/AddNoteCommandParserTest.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,83 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_A_CONTENT_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_A_PERSON_ID_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_A_TITLE_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_B_CONTENT_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_B_PERSON_ID_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_B_TITLE_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_NOTE_A_CONTENT; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_NOTE_A_PERSON_ID; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_NOTE_A_TITLE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE_CONTENT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE_TITLE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PERSON_ID; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
import static seedu.address.testutil.TypicalNotes.NOTE_A; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.AddNoteCommand; | ||
import seedu.address.model.note.Note; | ||
|
||
public class AddNoteCommandParserTest { | ||
private AddNoteCommandParser parser = new AddNoteCommandParser(); | ||
|
||
@Test | ||
public void parse_allFieldsPresent_success() { | ||
Note expectedNote = NOTE_A; | ||
|
||
// whitespace only preamble | ||
assertParseSuccess(parser, PREAMBLE_WHITESPACE + NOTE_A_PERSON_ID_DESC + NOTE_A_TITLE_DESC | ||
+ NOTE_A_CONTENT_DESC, | ||
new AddNoteCommand(Integer.parseInt(VALID_NOTE_A_PERSON_ID), expectedNote)); | ||
} | ||
|
||
@Test | ||
public void parse_repeatedNonTagValue_failure() { | ||
String validExpectedNoteString = NOTE_B_PERSON_ID_DESC + NOTE_B_TITLE_DESC + NOTE_B_CONTENT_DESC; | ||
|
||
// multiple person ids | ||
assertParseFailure(parser, NOTE_A_PERSON_ID_DESC + validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PERSON_ID)); | ||
|
||
// multiple titles | ||
assertParseFailure(parser, NOTE_A_TITLE_DESC + validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NOTE_TITLE)); | ||
|
||
// multiple contents | ||
assertParseFailure(parser, NOTE_A_CONTENT_DESC + validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NOTE_CONTENT)); | ||
|
||
// multiple fields repeated | ||
assertParseFailure(parser, | ||
validExpectedNoteString + NOTE_A_PERSON_ID_DESC + NOTE_A_TITLE_DESC + NOTE_A_CONTENT_DESC | ||
+ validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PERSON_ID, PREFIX_NOTE_TITLE, PREFIX_NOTE_CONTENT)); | ||
} | ||
|
||
@Test | ||
public void parse_compulsoryFieldMissing_failure() { | ||
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddNoteCommand.MESSAGE_USAGE); | ||
|
||
// missing person id prefix | ||
assertParseFailure(parser, VALID_NOTE_A_PERSON_ID + NOTE_A_TITLE_DESC + NOTE_A_CONTENT_DESC, | ||
expectedMessage); | ||
|
||
// missing title prefix | ||
assertParseFailure(parser, NOTE_A_PERSON_ID_DESC + VALID_NOTE_A_TITLE + NOTE_A_CONTENT_DESC, | ||
expectedMessage); | ||
|
||
// missing content prefix | ||
assertParseFailure(parser, NOTE_A_PERSON_ID_DESC + NOTE_A_TITLE_DESC + VALID_NOTE_A_CONTENT, | ||
expectedMessage); | ||
|
||
// all prefixes missing | ||
assertParseFailure(parser, VALID_NOTE_A_PERSON_ID + VALID_NOTE_A_TITLE + VALID_NOTE_A_CONTENT, | ||
expectedMessage); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/test/java/seedu/address/logic/parser/DeleteNoteCommandParserTest.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,67 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_A_NOTE_ID_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_A_PERSON_ID_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_B_NOTE_ID_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.NOTE_B_PERSON_ID_DESC; | ||
import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_NOTE_A_NOTE_ID; | ||
import static seedu.address.logic.commands.CommandTestUtil.VALID_NOTE_A_PERSON_ID; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE_ID; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PERSON_ID; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.DeleteNoteCommand; | ||
|
||
public class DeleteNoteCommandParserTest { | ||
private DeleteNoteCommandParser parser = new DeleteNoteCommandParser(); | ||
|
||
@Test | ||
public void parse_allFieldsPresent_success() { | ||
// whitespace only preamble | ||
assertParseSuccess(parser, PREAMBLE_WHITESPACE + NOTE_A_PERSON_ID_DESC + NOTE_A_NOTE_ID_DESC, | ||
new DeleteNoteCommand(Integer.parseInt(VALID_NOTE_A_PERSON_ID), | ||
Integer.parseInt(VALID_NOTE_A_NOTE_ID))); | ||
} | ||
|
||
@Test | ||
public void parse_repeatedNonTagValue_failure() { | ||
String validExpectedNoteString = NOTE_B_PERSON_ID_DESC + NOTE_B_NOTE_ID_DESC; | ||
|
||
// multiple person ids | ||
assertParseFailure(parser, NOTE_A_PERSON_ID_DESC + validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PERSON_ID)); | ||
|
||
// multiple note ids | ||
assertParseFailure(parser, NOTE_A_NOTE_ID_DESC + validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NOTE_ID)); | ||
|
||
// multiple fields repeated | ||
assertParseFailure(parser, | ||
validExpectedNoteString + NOTE_A_PERSON_ID_DESC + NOTE_A_NOTE_ID_DESC | ||
+ validExpectedNoteString, | ||
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PERSON_ID, PREFIX_NOTE_ID)); | ||
} | ||
|
||
@Test | ||
public void parse_compulsoryFieldMissing_failure() { | ||
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteNoteCommand.MESSAGE_USAGE); | ||
|
||
// missing person id prefix | ||
assertParseFailure(parser, VALID_NOTE_A_PERSON_ID + NOTE_A_NOTE_ID_DESC, | ||
expectedMessage); | ||
|
||
// missing note id prefix | ||
assertParseFailure(parser, NOTE_A_PERSON_ID_DESC + VALID_NOTE_A_NOTE_ID, | ||
expectedMessage); | ||
|
||
// all prefixes missing | ||
assertParseFailure(parser, VALID_NOTE_A_PERSON_ID + VALID_NOTE_A_NOTE_ID, | ||
expectedMessage); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/seedu/address/model/note/NoteContentTest.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,28 @@ | ||
package seedu.address.model.note; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class NoteContentTest { | ||
@Test | ||
public void equals() { | ||
NoteContent content = NoteContent.fromString("Valid Note Content"); | ||
|
||
// same values -> returns true | ||
assertTrue(content.equals(NoteContent.fromString("Valid Note Content"))); | ||
|
||
// same object -> returns true | ||
assertTrue(content.equals(content)); | ||
|
||
// null -> returns false | ||
assertFalse(content.equals(null)); | ||
|
||
// different types -> returns false | ||
assertFalse(content.equals(5.0f)); | ||
|
||
// different values -> returns false | ||
assertFalse(content.equals(NoteContent.fromString("Other Valid Note Content"))); | ||
} | ||
} |
Oops, something went wrong.