Skip to content

Commit

Permalink
Merge pull request #51 from wamps-jp/branch-updating-UG
Browse files Browse the repository at this point in the history
Update `ListCommand` test cases and documentation
  • Loading branch information
McNaBry authored Oct 20, 2023
2 parents 0867710 + fb0049d commit f455f11
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 2 deletions.
25 changes: 25 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,31 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

Use case resumes at step 2.


**Use case: List contacts**

**MSS**

1. User requests to list contacts
2. Jobby shows a list of contacts

Use case ends.

**Extensions**

* 1a. User requests to list organizations.

* 1a1. Jobby shows a list of organizations.

Use case ends.

* 1b. User requests to list recruiters.

* 1b1. Jobby shows a list of recruiters.

Use case ends.


*{More to be added}*

### Non-Functional Requirements
Expand Down
8 changes: 6 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,15 @@ Examples:

### Listing all contacts: `list`

_{To be updated...}_
Format: `list [--org/--rec]`

Shows a list of all contacts in the address book.
Supplying `--org` lists only Organizations while supplying `--rec` lists only Recruiters.

Format: `list`
Examples:
* `list`
* `list --org`
* `list --rec`


### Editing a contact: `edit`
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/seedu/address/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ public CommandResult execute(Model model) {
}
return new CommandResult(MESSAGE_SUCCESS_ALL_CONTACTS);
}

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

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

ListCommand otherListCommand = (ListCommand) other;
return predicate.equals(otherListCommand.predicate);
}
}
31 changes: 31 additions & 0 deletions src/test/java/seedu/address/logic/commands/ListCommandTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
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.logic.commands.CommandTestUtil.showContactAtIndex;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_CONTACTS;
import static seedu.address.model.Model.PREDICATE_SHOW_ONLY_ORGANIZATIONS;
import static seedu.address.model.Model.PREDICATE_SHOW_ONLY_RECRUITERS;
import static seedu.address.testutil.TypicalContacts.getTypicalAddressBook;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_CONTACT;

Expand Down Expand Up @@ -39,4 +43,31 @@ public void execute_listIsFiltered_showsEverything() {
assertCommandSuccess(new ListCommand(PREDICATE_SHOW_ALL_CONTACTS),
model, ListCommand.MESSAGE_SUCCESS_ALL_CONTACTS, expectedModel);
}

@Test
public void equals() {
ListCommand showAllListCommand = new ListCommand(PREDICATE_SHOW_ALL_CONTACTS);
ListCommand organizationListCommand = new ListCommand(PREDICATE_SHOW_ONLY_ORGANIZATIONS);
ListCommand recruiterListCommand = new ListCommand(PREDICATE_SHOW_ONLY_RECRUITERS);

// same object -> returns true
assertTrue(showAllListCommand.equals(showAllListCommand));
assertTrue(organizationListCommand.equals(organizationListCommand));
assertTrue(recruiterListCommand.equals(recruiterListCommand));

// same predicate -> returns true
ListCommand showAllListCommandCopy = new ListCommand(PREDICATE_SHOW_ALL_CONTACTS);
assertTrue(showAllListCommand.equals(showAllListCommandCopy));

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

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

// different predicate -> returns false
assertFalse(showAllListCommand.equals(organizationListCommand));
assertFalse(showAllListCommand.equals(recruiterListCommand));
assertFalse(organizationListCommand.equals(recruiterListCommand));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package seedu.address.logic.parser;

import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_CONTACTS;

import org.junit.jupiter.api.Test;

import seedu.address.logic.commands.ListCommand;

public class ListCommandParserTest {

private ListCommandParser parser = new ListCommandParser();

@Test
public void parse_validArgs_returnsListCommand() {
assertParseSuccess(parser, "", new ListCommand(PREDICATE_SHOW_ALL_CONTACTS));
}
}

0 comments on commit f455f11

Please sign in to comment.