Skip to content
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

Add functionality to whitelist and blacklist commands #156

Merged
merged 12 commits into from
Nov 4, 2024
Merged
17 changes: 14 additions & 3 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ Examples:

Allows updating of various statuses of an existing client.

Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…​
[ps/PROJECT_STATUS] [py/PAYMENT_STATUS] [cs/CLIENT_STATUS] [d/DEADLINE]`
Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [d/DEADLINE]
[t/TAG]…​ [ps/PROJECT_STATUS] [py/PAYMENT_STATUS] [cs/CLIENT_STATUS]`

* `NAME` Acceptable values are same as in add command
* `PHONE_NUMBER` Acceptable values are same as in add command
Expand Down Expand Up @@ -160,7 +160,7 @@ The deadline field will show an `OVERDUE` label if the deadline has passed and t

Finds persons in client list who match parameters specified.

Format: `find [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]… [ps/PROJECT_STATUS] [py/PAYMENT_STATUS] [cs/CLIENT_STATUS] [d/DEADLINE]`
Format: `find [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [d/DEADLINE] [t/TAG]… [ps/PROJECT_STATUS] [py/PAYMENT_STATUS] [cs/CLIENT_STATUS]`

* All values matched for any parameter are **case-insensitive**.
* The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans`.
Expand All @@ -178,6 +178,17 @@ Examples:

![result for 'find alex david'](images/findAlexDavidResult.png)


<div markdown="span" class="alert alert-primary">:bulb: **Tip:**
#### Shortcuts: Finding blacklisted/whitelisted clients

To find all clients that are blacklisted (with no other parameters), the command `blacklist` can be entered.

Similarly, the `whitelist` command can be entered to find all clients who are whitelisted.

_Note: both of these commands need to be entered without any parameters otherwise the app responds with an error message._
</div>

### Delete Client Details : `delete`

Deletes the specified person from Clientele+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public class BlacklistCommand extends Command {

public static final String COMMAND_WORD = "blacklist";

public static final String MESSAGE_USAGE = COMMAND_WORD + " INDEX : adds a person to the blacklist."
+ "\nExample: '" + COMMAND_WORD + " 2' blacklists the 2nd client in the list.";
public static final String MESSAGE_USAGE = COMMAND_WORD + " INDEX : adds a client to the blacklist."
+ "\nExample: '" + COMMAND_WORD + " 2' blacklists the 2nd client in the list."
+ "\nAlternate use: entering '" + COMMAND_WORD + "' shows all blacklisted clients.";

public static final String MESSAGE_BLACKLIST_PERSON_SUCCESS = "Blacklisted Person: %1$s";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.parser.FindCommandParser;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.Model;

/**
* Lists out all blacklisted clients
*/
public class BlacklistListCommand extends BlacklistCommand {

/**
* Instantiates a {@code BlacklistListCommand} object.
*/
public BlacklistListCommand() {
super(Index.fromZeroBased(0)); // this is irrelevant but necessary
}

Check warning on line 20 in src/main/java/seedu/address/logic/commands/BlacklistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/BlacklistListCommand.java#L19-L20

Added lines #L19 - L20 were not covered by tests

@Override
public CommandResult execute(Model model) {
requireNonNull(model);

Check warning on line 24 in src/main/java/seedu/address/logic/commands/BlacklistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/BlacklistListCommand.java#L24

Added line #L24 was not covered by tests

try {
// make the find command do the hard work
return (new FindCommandParser().parse("find cs/blacklisted")).execute(model);
} catch (ParseException pe) {
return null; // this will never happen

Check warning on line 30 in src/main/java/seedu/address/logic/commands/BlacklistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/BlacklistListCommand.java#L28-L30

Added lines #L28 - L30 were not covered by tests

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By any chance would it be good to have a good error message/log message anyways? In case find command changes or other code is modified? But for now, I agree, it won't happen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion of the find command is reliant on the ArgumentPredicate being changed, which is highly unlikely. But in the future I will be decoupling the blacklist command from the find command entirely; this was just a quick addition that I did not want to initially spend too much time on, so I could focus on the test cases and the whitelist command.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class WhitelistCommand extends Command {
+ ": removes person from the blacklist and sets their client status to NEW_CLIENT_STATUS."
+ " NEW_CLIENT_STATUS must be 'old', 'active', 'potential' or 'unresponsive'."
+ "\nExample: '" + COMMAND_WORD + " 2 cs/old' sets the client status of the 2nd "
+ "client in the list as 'old' after removing them from the blacklist.";
+ "client in the list as 'old' after removing them from the blacklist."
+ "\nAlternate use: entering '" + COMMAND_WORD + "' will list out all clients NOT on the blacklist";

public static final String MESSAGE_WHITELIST_PERSON_SUCCESS = "Whitelisted Person: %1$s";
public static final String MESSAGE_CANNOT_WHITELIST = "This person is not on the blacklist: %1$s";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.Messages;
import seedu.address.model.Model;
import seedu.address.model.person.ArgumentPredicateToFail;
import seedu.address.model.person.ClientStatus;

/**
* Lists out all whitelisted clients
*/
public class WhitelistListCommand extends WhitelistCommand {

/**
* Instantiates a {@code WhitelistListCommand} object.
*
* @param argPredToFail an argument predicate that should fail
*/
public WhitelistListCommand() {
// this is irrelevant but necessary
super(Index.fromZeroBased(0), new ClientStatus("old"));
}

Check warning on line 24 in src/main/java/seedu/address/logic/commands/WhitelistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/WhitelistListCommand.java#L23-L24

Added lines #L23 - L24 were not covered by tests

@Override
public CommandResult execute(Model model) {
requireNonNull(model);

Check warning on line 28 in src/main/java/seedu/address/logic/commands/WhitelistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/WhitelistListCommand.java#L28

Added line #L28 was not covered by tests

// here, the predicate dictates that the client status should be blacklisted;
// hence if the predicate fails (ensured by the ArgumentPredicateToFail object),
// the client is not blacklisted => they are whitelisted
model.updateFilteredPersonList(ArgumentPredicateToFail.getNotBlacklistedPredicate());

Check warning on line 33 in src/main/java/seedu/address/logic/commands/WhitelistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/WhitelistListCommand.java#L33

Added line #L33 was not covered by tests

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding, how come there is a different execution for whitelistcommand and blacklistcommand? Couldn't it be easier if there was a predicate 'getBlacklistedPredicate' that kept things consistent and reduces Blacklist's dependence on other code? That being said, I think this still works 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I will be decoupling the blacklist command to make it work more like the whitelist command later on, that was just an easy temporary fix.


return new CommandResult(
String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size()));

Check warning on line 36 in src/main/java/seedu/address/logic/commands/WhitelistListCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/WhitelistListCommand.java#L35-L36

Added lines #L35 - L36 were not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package seedu.address.logic.parser;

import static java.util.Objects.requireNonNull;
// import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.BlacklistCommand;
import seedu.address.logic.commands.BlacklistListCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
Expand All @@ -13,20 +14,28 @@
public class BlacklistCommandParser implements Parser<BlacklistCommand> {

/**
* Parses the given {@code String} of arguments in the context of the EditCommand
* and returns an EditCommand object for execution.
* Parses the given {@code String} of arguments in the context of the BlacklistCommand
* and returns a BlacklistCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public BlacklistCommand parse(String args) throws ParseException {
requireNonNull(args);
// requireNonNull(args);
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args);

Index index;
String preamble = argMultimap.getPreamble();

Check warning on line 26 in src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java#L26

Added line #L26 was not covered by tests

try {
index = ParserUtil.parseIndex(argMultimap.getPreamble());
index = ParserUtil.parseIndex(preamble);

Check warning on line 29 in src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java#L29

Added line #L29 was not covered by tests
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, BlacklistCommand.MESSAGE_USAGE), pe);
if (preamble.equals("")) {
// only allow "blacklist" with no params as the valid command
return new BlacklistListCommand();

Check warning on line 33 in src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java#L33

Added line #L33 was not covered by tests
} else {
// any non-empty non-index params throws an error
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,

Check warning on line 36 in src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/BlacklistCommandParser.java#L36

Added line #L36 was not covered by tests
BlacklistCommand.MESSAGE_USAGE), pe);
}
}

return new BlacklistCommand(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.WhitelistCommand;
import seedu.address.logic.commands.WhitelistListCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.ClientStatus;

Expand All @@ -17,15 +18,16 @@
/**
* Checks if the new client status is valid.
* The new client status must be 'old', 'active' or 'potential',
* it cannot be 'blaclisted' (despite that being a valid client status).
* it cannot be 'blacklisted' (despite it being a valid client status).
* {@code clientStatus} will already be validated.
*/
public boolean isValidNewClientStatus(ClientStatus clientStatus) {
return !clientStatus.isBlacklisted();
}

/**
* Parses the given {@code String} of arguments in the context of the EditCommand
* and returns an EditCommand object for execution.
* Parses the given {@code String} of arguments in the context of the WhitelistCommand
* and returns a WhitelistCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public WhitelistCommand parse(String args) throws ParseException {
Expand All @@ -35,21 +37,26 @@

Index index;
ClientStatus newClientStatus;
String preamble = argMultimap.getPreamble();

Check warning on line 40 in src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java#L40

Added line #L40 was not covered by tests

try {
index = ParserUtil.parseIndex(argMultimap.getPreamble());
index = ParserUtil.parseIndex(preamble);

Check warning on line 43 in src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java#L43

Added line #L43 was not covered by tests
} catch (ParseException pe) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, WhitelistCommand.MESSAGE_USAGE), pe);
if (preamble.equals("") && !argMultimap.getValue(PREFIX_CLIENT_STATUS).isPresent()) {
return new WhitelistListCommand();

Check warning on line 46 in src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java#L46

Added line #L46 was not covered by tests
} else {
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, WhitelistCommand.MESSAGE_USAGE), pe);

Check warning on line 49 in src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java#L48-L49

Added lines #L48 - L49 were not covered by tests
}
}

if (argMultimap.getValue(PREFIX_CLIENT_STATUS).isPresent()) {
newClientStatus = ParserUtil.parseClientStatus(argMultimap.getValue(PREFIX_CLIENT_STATUS).get());
} else {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, WhitelistCommand.MESSAGE_USAGE));
}

if (isValidNewClientStatus(newClientStatus)) {
return new WhitelistCommand(index, newClientStatus);
if (isValidNewClientStatus(newClientStatus)) {
return new WhitelistCommand(index, newClientStatus);

Check warning on line 56 in src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java#L56

Added line #L56 was not covered by tests
} else {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, WhitelistCommand.MESSAGE_USAGE));

Check warning on line 58 in src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/WhitelistCommandParser.java#L58

Added line #L58 was not covered by tests
}
} else {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, WhitelistCommand.MESSAGE_USAGE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
inputParameters = parameterMap;
}

public Map<String, Object> getInputParameters() {
return this.inputParameters;

Check warning on line 32 in src/main/java/seedu/address/model/person/ArgumentPredicate.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicate.java#L32

Added line #L32 was not covered by tests
}

private void addIfPresent(String key, Predicate<Person> predicate,
Person person, List<Boolean> validParameters) {
assert key != null : "Key should not be null";
Expand Down
131 changes: 131 additions & 0 deletions src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package seedu.address.model.person;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.model.tag.Tag;

/**
* Like an {@code ArgumentPredicate}, but instead tests to see if the Person fails the predicate
*/
public class ArgumentPredicateToFail extends ArgumentPredicate {

private static ArgumentPredicateToFail notBlacklistedPredicate;

/**
* Constructs an {@code ArgumentPredicateToFail}
*
* @param parameterMap A map with parameters inputted by user
*/
public ArgumentPredicateToFail(Map<String, Object> parameterMap) {
super(parameterMap);
}

Check warning on line 29 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L28-L29

Added lines #L28 - L29 were not covered by tests

public static ArgumentPredicateToFail getNotBlacklistedPredicate() {
if (notBlacklistedPredicate == null) {
Map<String, Object> parameterMap = new HashMap<>();

Check warning on line 33 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L33

Added line #L33 was not covered by tests

parameterMap.put(ClientStatus.CLIENT_STATUS_KEY, new ClientStatus("blacklisted"));

Check warning on line 35 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L35

Added line #L35 was not covered by tests

Set<Tag> tagList = new HashSet<>();
parameterMap.put(Tag.TAG_KEY, tagList);

Check warning on line 38 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L37-L38

Added lines #L37 - L38 were not covered by tests

notBlacklistedPredicate = new ArgumentPredicateToFail(parameterMap);

Check warning on line 40 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L40

Added line #L40 was not covered by tests
}

return notBlacklistedPredicate;

Check warning on line 43 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L43

Added line #L43 was not covered by tests
}

private void addIfPresent(String key, Predicate<Person> predicate,
Person person, List<Boolean> validParameters) {
assert key != null : "Key should not be null";
assert predicate != null : "Predicate should not be null";
assert person != null : "Person should not be null";
assert validParameters != null : "Valid parameters list should not be null";
if (getInputParameters().containsKey(key)) {
validParameters.add(!predicate.test(person));
}
}

Check warning on line 55 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L55

Added line #L55 was not covered by tests

private void addIfTagPresent(Set<Tag> tags, Predicate<Person> predicate,
Person person, List<Boolean> validParameters) {
assert tags != null : "Tags should not be null";
assert predicate != null : "Predicate should not be null";
assert person != null : "Person should not be null";
assert validParameters != null : "Valid parameters list should not be null";
if (!tags.isEmpty()) {
validParameters.add(!predicate.test(person));
}
}

Check warning on line 66 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L66

Added line #L66 was not covered by tests

private List<Boolean> getValidParameters(Person person) {
List<Boolean> validParameters = new ArrayList<>();
addIfPresent(Name.NAME_KEY, p -> {
String[] nameKeywords = getInputParameters().get("name").toString().split("\\s+");
NameContainsKeywordsPredicate namePredicate =
new NameContainsKeywordsPredicate(Arrays.asList(nameKeywords));
return namePredicate.test(p);

Check warning on line 74 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L69-L74

Added lines #L69 - L74 were not covered by tests
}, person, validParameters);

addIfPresent(Phone.PHONE_KEY, p -> getInputParameters().get("phone").equals(p.getPhone()),

Check warning on line 77 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L77

Added line #L77 was not covered by tests
person, validParameters);

addIfPresent(Email.EMAIL_KEY, p -> getInputParameters().get("email").equals(p.getEmail()),

Check warning on line 80 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L80

Added line #L80 was not covered by tests
person, validParameters);

addIfPresent(Address.ADDRESS_KEY, p -> getInputParameters().get("address").equals(p.getAddress()),

Check warning on line 83 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L83

Added line #L83 was not covered by tests
person, validParameters);

addIfPresent(ProjectStatus.PROJECT_STATUS_KEY, p -> getInputParameters().get("project status")
.equals(p.getProjectStatus()), person, validParameters);

Check warning on line 87 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L86-L87

Added lines #L86 - L87 were not covered by tests

addIfPresent(PaymentStatus.PAYMENT_STATUS_KEY, p -> getInputParameters().get("payment status")
.equals(p.getPaymentStatus()), person, validParameters);

Check warning on line 90 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L89-L90

Added lines #L89 - L90 were not covered by tests

addIfPresent(ClientStatus.CLIENT_STATUS_KEY, p -> getInputParameters().get("client status")
.equals(p.getClientStatus()), person, validParameters);

Check warning on line 93 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L92-L93

Added lines #L92 - L93 were not covered by tests

addIfPresent(Deadline.DEADLINE_KEY, p -> getInputParameters().get("deadline")
.equals(p.getDeadline()), person, validParameters);

Check warning on line 96 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L95-L96

Added lines #L95 - L96 were not covered by tests

@SuppressWarnings("unchecked")
Set<Tag> tags = (Set<Tag>) getInputParameters().get(Tag.TAG_KEY);
addIfTagPresent(tags, p -> tags.stream()
.anyMatch(p.getTags()::contains), person, validParameters);

Check warning on line 101 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L99-L101

Added lines #L99 - L101 were not covered by tests

return validParameters;

Check warning on line 103 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L103

Added line #L103 was not covered by tests
}

@Override
public boolean test(Person person) {
List<Boolean> validParameters = getValidParameters(person);
return validParameters.stream().allMatch(Boolean::booleanValue);

Check warning on line 109 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L108-L109

Added lines #L108 - L109 were not covered by tests
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;

Check warning on line 115 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L115

Added line #L115 was not covered by tests
}

// instanceof handles nulls
if (!(other instanceof ArgumentPredicateToFail)) {
return false;

Check warning on line 120 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L120

Added line #L120 was not covered by tests
}

ArgumentPredicateToFail argumentPredicateToFail = (ArgumentPredicateToFail) other;
return getInputParameters().equals(argumentPredicateToFail.getInputParameters());

Check warning on line 124 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L123-L124

Added lines #L123 - L124 were not covered by tests
}

@Override
public String toString() {
return new ToStringBuilder(this).add("parameters to fail", getInputParameters()).toString();

Check warning on line 129 in src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/model/person/ArgumentPredicateToFail.java#L129

Added line #L129 was not covered by tests
}
}
Loading