forked from nus-cs2103-AY2122S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Batch student status update #62
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 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,11 @@ | ||
|
||
| Layout | Page | | ||
| --- | --- | | ||
| User Guide | Link | | ||
| Quick start | Link | | ||
| Features | Link | | ||
| Command Summary | Link | | ||
| Quick Links | | ||
|-----------------| | ||
| Glossary | | ||
| User Guide | | ||
| Quick start | | ||
| Features | | ||
| Command Summary | | ||
|
||
|
||
Ultimate DivocTracker is a desktop app for managing COVID-19 contacts in school admin, optimized for use via a Command Line Interface (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, Ultimate DivocTracker can get your contact management tasks done faster than traditional GUI apps. | ||
|
@@ -15,8 +16,8 @@ Ultimate DivocTracker is a desktop app for managing COVID-19 contacts in school | |
- Adding a student: add | ||
- Listing all students: list | ||
- Find students by name: find_by_name | ||
- Find student by status: find_by_status | ||
- Find student by class: find_by_class | ||
- Find student by status: findstatus | ||
- Find student by class: findclasscode | ||
- Deleting a student: delete_student | ||
- Update COVID-19 status: update_status | ||
- Exiting the program : exit | ||
|
@@ -53,22 +54,22 @@ Find an existing student in the application by their name | |
- Example: | ||
- `find_by_name john` | ||
|
||
## Find a student by status: `find_by_status` | ||
## Find a student by status: `findstatus` | ||
Find an existing student in the application by their Covid-19 Status | ||
- Format: `find_by_status STATUS` | ||
- Format: `findstatus STATUS` | ||
- Returns a list of students with the specified `STATUS` | ||
- `STATUS` is case-insensitive | ||
- Example: | ||
- `find_by_status positive` | ||
- `find_by_status negative` | ||
- `findstatus positive` | ||
- `findstatus negative` | ||
|
||
## Find student by class: `find_by_class` | ||
## Find student by class: `findclasscode` | ||
Finds an existing student in the address book by their class. | ||
- Format: `find_by_class CLASS` | ||
- Format: `findclasscode CLASS` | ||
- Returns a list of students with the specified `CLASS`. | ||
- `CLASS` is case-insensitive | ||
- Example: | ||
- `find_by_class 4A` | ||
- `findclasscode 4A` | ||
|
||
## Updating persons status: `update_status` | ||
Updates persons status to the given status. | ||
|
@@ -111,8 +112,8 @@ AddressBook data are saved as a JSON file `[JAR file location]/data/addressbook. | |
| Delete a student | `delete_student INDEX`<br/>e.g., `delete_student 3` | | ||
| Edit | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS]`<br/>e.g., `edit 2 n/James Lee e/[email protected]` | | ||
| Find by name | `find_by_name NAME [MORE_NAME]`<br/>e.g., `find_by_name James Jake` | | ||
| Find by status | `find_by_status STATUS`<br/>e.g., `find_by_status positive` | | ||
| Find by class | `find_by_class CLASS`<br/>e.g., `find_by_class 4A` | | ||
| Find by status | `findstatus STATUS`<br/>e.g., `find_by_status positive` | | ||
| Find by class | `findclasscode CLASS`<br/>e.g., `find_by_class 4A` | | ||
| List | `list` | | ||
| Update status | `update_status INDEX STATUS`<br/>e.g., `update_status 54 positive` | | ||
| Exit | `exit` | ||
| Exit | `exit` | |
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
67 changes: 67 additions & 0 deletions
67
src/test/java/seedu/address/logic/commands/FindStatusTest.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.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 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 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.