forked from nus-cs2103-AY2122S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Batch student status update #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
louisdavinlie
merged 18 commits into
AY2122S2-CS2103T-T12-1:master
from
joshuayapwj98:batch-student-status-update
Mar 12, 2022
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e391c49
Add checks for Status and ClassCode
joshuayapwj98 3263757
Add steps to approach batch student update
joshuayapwj98 16e18a5
Fix indentation
joshuayapwj98 6684482
Change location of documentation
joshuayapwj98 fe57bf8
- Update UG for changes to new methods added - findstatus
lzf834 6e1df54
Checkstyle changes
lzf834 af3e05e
Merge pull request #58 from e0544333/status-edit-command
Fenway17 ae17e66
Merge pull request #63 from lzf834/v1.2_filter_command
Fenway17 091be92
Update fenway17.md
Fenway17 3723bfb
Merge pull request #64 from Fenway17/master
lzf834 84ac186
Implement JUnit Tests for Status and Status-related functions
lzf834 a79543d
Checkstyle changes for Status-related Tests
lzf834 7044010
CheckStyle Changes
lzf834 92aa24c
Merge pull request #69 from lzf834/v1.2_filter_command
whoisjunhong 25139a5
Add filtered list by ClassCode and validation of student
whoisjunhong fb5a71d
Merge pull request #70 from whoisjunhong/v1.2_batch_update_info
Fenway17 11354ef
Auto stash before merge of "master" and "origin/master"
joshuayapwj98 034b174
Merge remote-tracking branch 'origin/batch-student-status-update' int…
joshuayapwj98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
67 changes: 67 additions & 0 deletions
67
src/test/java/seedu/address/logic/commands/FindStatusTest.java
This file contains hidden or 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.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 static seedu.address.commons.core.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; | ||
| import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
| import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import seedu.address.model.Model; | ||
| import seedu.address.model.ModelManager; | ||
| import seedu.address.model.UserPrefs; | ||
| import seedu.address.model.person.StatusContainsKeywordsPredicate; | ||
|
|
||
| public class FindStatusTest { | ||
| private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
| private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
|
|
||
| @Test | ||
| public void equals() { | ||
| StatusContainsKeywordsPredicate firstPredicate = | ||
| new StatusContainsKeywordsPredicate(Collections.singletonList("Positive")); | ||
| StatusContainsKeywordsPredicate secondPredicate = | ||
| new StatusContainsKeywordsPredicate(Collections.singletonList("Negative")); | ||
|
|
||
| FindStatusCommand findFirstCommand = new FindStatusCommand(firstPredicate); | ||
| FindStatusCommand findSecondCommand = new FindStatusCommand(secondPredicate); | ||
|
|
||
| // same object -> returns true | ||
| assertTrue(findFirstCommand.equals(findFirstCommand)); | ||
|
|
||
| // same values -> returns true | ||
| FindStatusCommand findFirstCommandCopy = new FindStatusCommand(firstPredicate); | ||
| assertTrue(findFirstCommand.equals(findFirstCommandCopy)); | ||
|
|
||
| // different types -> returns false | ||
| assertFalse(findFirstCommand.equals(1)); | ||
|
|
||
| // null -> returns false | ||
| assertFalse(findFirstCommand.equals(null)); | ||
|
|
||
| // different person -> returns false | ||
| assertFalse(findFirstCommand.equals(findSecondCommand)); | ||
| } | ||
|
|
||
| @Test | ||
| public void execute_zeroKeywords_noPersonFound() { | ||
| String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); | ||
| StatusContainsKeywordsPredicate predicate = preparePredicate(" "); | ||
| FindStatusCommand command = new FindStatusCommand(predicate); | ||
| expectedModel.updateFilteredPersonList(predicate); | ||
| assertCommandSuccess(command, model, expectedMessage, expectedModel); | ||
| assertEquals(Collections.emptyList(), model.getFilteredPersonList()); | ||
| } | ||
|
|
||
| /** | ||
| * Parses {@code userInput} into a {@code StatusContainsKeywordsPredicate}. | ||
| */ | ||
| private StatusContainsKeywordsPredicate preparePredicate(String userInput) { | ||
| return new StatusContainsKeywordsPredicate(Arrays.asList(userInput.split("\\s+"))); | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
src/test/java/seedu/address/logic/parser/FindStatusCommandParserTest.java
This file contains hidden or 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,35 @@ | ||
| package seedu.address.logic.parser; | ||
|
|
||
| import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
| import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; | ||
| import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import seedu.address.logic.commands.FindStatusCommand; | ||
| import seedu.address.model.person.StatusContainsKeywordsPredicate; | ||
|
|
||
| public class FindStatusCommandParserTest { | ||
| private FindStatusCommandParser parser = new FindStatusCommandParser(); | ||
|
|
||
| @Test | ||
| public void parse_emptyArg_throwsParseException() { | ||
| assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT, | ||
| FindStatusCommand.MESSAGE_USAGE)); | ||
|
|
||
| // multiple whitespaces between keywords | ||
| assertParseFailure(parser, " \n Positive \n \t Negative \t", String.format( | ||
| MESSAGE_INVALID_COMMAND_FORMAT, FindStatusCommand.ERRMSG_STATUS)); | ||
| } | ||
|
|
||
| @Test | ||
| public void parse_validArgs_returnsFindCommand() { | ||
| // no leading and trailing whitespaces | ||
| FindStatusCommand expectedFindStatusCommand = | ||
| new FindStatusCommand(new StatusContainsKeywordsPredicate(Arrays.asList("Positive"))); | ||
| assertParseSuccess(parser, "Positive", expectedFindStatusCommand); | ||
|
|
||
| } | ||
| } |
64 changes: 64 additions & 0 deletions
64
src/test/java/seedu/address/model/person/StatusContainsKeywordsPredicateTest.java
This file contains hidden or 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,64 @@ | ||
| package seedu.address.model.person; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import seedu.address.testutil.PersonBuilder; | ||
|
|
||
| public class StatusContainsKeywordsPredicateTest { | ||
| @Test | ||
| public void equals() { | ||
| List<String> firstPredicateKeywordList = Collections.singletonList("Positive"); | ||
| List<String> secondPredicateKeywordList = Arrays.asList("Positive", "Negative"); | ||
|
|
||
| StatusContainsKeywordsPredicate firstPredicate = new | ||
| StatusContainsKeywordsPredicate(firstPredicateKeywordList); | ||
| StatusContainsKeywordsPredicate secondPredicate = new | ||
| StatusContainsKeywordsPredicate(secondPredicateKeywordList); | ||
|
|
||
| // same object -> returns true | ||
| assertTrue(firstPredicate.equals(firstPredicate)); | ||
|
|
||
| // same values -> returns true | ||
| StatusContainsKeywordsPredicate firstPredicateCopy = new | ||
| StatusContainsKeywordsPredicate(firstPredicateKeywordList); | ||
| assertTrue(firstPredicate.equals(firstPredicateCopy)); | ||
|
|
||
| // different types -> returns false | ||
| assertFalse(firstPredicate.equals(1)); | ||
|
|
||
| // null -> returns false | ||
| assertFalse(firstPredicate.equals(null)); | ||
|
|
||
| // different person -> returns false | ||
| assertFalse(firstPredicate.equals(secondPredicate)); | ||
| } | ||
|
|
||
| @Test | ||
| public void test_statusContainsKeywords_returnsTrue() { | ||
| // One keyword | ||
| StatusContainsKeywordsPredicate predicate = new | ||
| StatusContainsKeywordsPredicate(Collections.singletonList("Positive")); | ||
| assertTrue(predicate.test(new PersonBuilder().withStatus("Positive").build())); | ||
|
|
||
| // Exception thrown for >1 word in status | ||
| try { | ||
| new PersonBuilder().withStatus("Positive Negative").build(); | ||
| } catch (Exception e) { | ||
| assertTrue(e.getMessage() == Status.MESSAGE_CONSTRAINTS); | ||
| } | ||
|
|
||
| // Exception thrown for non-conforming syntax in status | ||
| try { | ||
| new PersonBuilder().withStatus("Pos").build(); | ||
| } catch (Exception e) { | ||
| assertTrue(e.getMessage() == Status.MESSAGE_CONSTRAINTS); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also handle the case where a student's status has changed from positive to negative? When a student has recovered, their classmates' status should be negative instead of close contact if there is no more positive student in the class.