Skip to content

Commit

Permalink
Merge branch 'master' into V1.3-post-testing
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/test/java/seedu/address/logic/commands/CommandTestUtil.java
#	src/test/java/seedu/address/logic/commands/EditCommandTest.java
#	src/test/java/seedu/address/model/person/HousekeeperTest.java
#	src/test/java/seedu/address/model/person/LeadsFilterPredicateTest.java
#	src/test/java/seedu/address/testutil/PersonBuilder.java
#	src/test/java/seedu/address/testutil/TypicalPersons.java
  • Loading branch information
GERARDJM018 committed Apr 4, 2024
2 parents 5586bc7 + 81c6324 commit de5e4b5
Show file tree
Hide file tree
Showing 28 changed files with 604 additions and 500 deletions.
14 changes: 1 addition & 13 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public static class EditPersonDescriptor {
private Email email;
private Address address;
private Set<Tag> tags;
private Type type;
private BookingList bookingList;
private HousekeepingDetails details;
private Area area;
Expand All @@ -122,7 +121,6 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setEmail(toCopy.email);
setAddress(toCopy.address);
setTags(toCopy.tags);
setType(toCopy.type);
setBookingList(toCopy.bookingList);
setDetails(toCopy.details);
setArea(toCopy.area);
Expand All @@ -132,7 +130,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address, tags, type, area, bookingList);
return CollectionUtil.isAnyNonNull(name, phone, email, address, tags, area, bookingList);
}

public void setName(Name name) {
Expand Down Expand Up @@ -184,14 +182,6 @@ public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
}

public void setType(Type type) {
this.type = type;
}

public Optional<Type> getType() {
return Optional.ofNullable(type);
}

public void setBookingList(BookingList bookingList) {
this.bookingList = bookingList;
}
Expand Down Expand Up @@ -234,7 +224,6 @@ public boolean equals(Object other) {
&& Objects.equals(address, otherEditPersonDescriptor.address)
&& Objects.equals(area, otherEditPersonDescriptor.area)
&& Objects.equals(tags, otherEditPersonDescriptor.tags)
&& Objects.equals(type, otherEditPersonDescriptor.type)
&& Objects.equals(bookingList, otherEditPersonDescriptor.bookingList);
}

Expand All @@ -246,7 +235,6 @@ public String toString() {
.add("email", email)
.add("address", address)
.add("tags", tags)
.add("type", type)
.add("area", area)
.add("booking list", bookingList)
.toString();
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,6 @@ public void setHousekeeper(Housekeeper target, Housekeeper editedHousekeeper) {
housekeepers.setPerson(target, editedHousekeeper);
}

/**
* Removes {@code key} from this {@code AddressBook}.
* {@code key} must exist in the address book.
*/
public void removePerson(Person key) {
if (key.isClient()) {
clients.remove((Client) key);
} else {
housekeepers.remove((Housekeeper) key);
}
}

/**
* Removes {@code client} from this {@code AddressBook}.
* {@code client} must exist in the address book.
Expand Down
13 changes: 6 additions & 7 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.TYPE_DESC_AMY;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.AMY;

Expand All @@ -28,11 +27,11 @@
import seedu.address.model.ModelManager;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.UserPrefs;
import seedu.address.model.person.Person;
import seedu.address.model.person.Client;
import seedu.address.storage.JsonAddressBookStorage;
import seedu.address.storage.JsonUserPrefsStorage;
import seedu.address.storage.StorageManager;
import seedu.address.testutil.PersonBuilder;
import seedu.address.testutil.ClientBuilder;

public class LogicManagerTest {
private static final IOException DUMMY_IO_EXCEPTION = new IOException("dummy IO exception");
Expand Down Expand Up @@ -85,7 +84,7 @@ public void execute_storageThrowsAdException_throwsCommandException() {

@Test
public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() {
assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredPersonList().remove(0));
assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredClientList().remove(0));
}

/**
Expand Down Expand Up @@ -166,11 +165,11 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath)
logic = new LogicManager(model, storage);

// Triggers the saveAddressBook method by executing an add command
String addCommand = AddCommand.COMMAND_WORD + TYPE_DESC_AMY + NAME_DESC_AMY + PHONE_DESC_AMY
String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY
+ EMAIL_DESC_AMY + ADDRESS_DESC_AMY;
Person expectedPerson = new PersonBuilder(AMY).withTags().build();
Client expectedClient = new ClientBuilder(AMY).withTags().build();
ModelManager expectedModel = new ModelManager();
expectedModel.addPerson(expectedPerson);
expectedModel.addClient(expectedClient);
assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.person.Person;
import seedu.address.testutil.PersonBuilder;
import seedu.address.model.person.Client;
import seedu.address.model.person.Housekeeper;
import seedu.address.testutil.ClientBuilder;
import seedu.address.testutil.HousekeeperBuilder;

/**
* Contains integration tests (interaction with the Model) for {@code AddCommand}.
Expand All @@ -27,22 +29,41 @@ public void setUp() {
}

@Test
public void execute_newPerson_success() {
Person validPerson = new PersonBuilder().build();
public void execute_newClient_success() {
Client validClient = new ClientBuilder().build();

Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
expectedModel.addPerson(validPerson);
expectedModel.addClient(validClient);

assertCommandSuccess(new AddCommand(validPerson), model,
String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)),
assertCommandSuccess(new AddClientCommand(validClient), model,
String.format(AddClientCommand.MESSAGE_SUCCESS, Messages.formatClient(validClient)),
expectedModel);
}

@Test
public void execute_duplicatePerson_throwsCommandException() {
Person personInList = model.getAddressBook().getPersonList().get(0);
assertCommandFailure(new AddCommand(personInList), model,
AddCommand.MESSAGE_DUPLICATE_PERSON);
public void execute_newHousekeeper_success() {
Housekeeper validHousekeeper = new HousekeeperBuilder().build();

Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
expectedModel.addHousekeeper(validHousekeeper);

assertCommandSuccess(new AddHousekeeperCommand(validHousekeeper), model,
String.format(AddHousekeeperCommand.MESSAGE_SUCCESS, validHousekeeper),
expectedModel);
}

@Test
public void execute_duplicateClient_throwsCommandException() {
Client clientInList = model.getAddressBook().getClientList().get(0);
assertCommandFailure(new AddClientCommand(clientInList), model,
AddClientCommand.MESSAGE_DUPLICATE_CLIENT);
}

@Test
public void execute_duplicateHousekeeper_throwsCommandException() {
Housekeeper housekeeperInList = model.getAddressBook().getHousekeeperList().get(0);
assertCommandFailure(new AddHousekeeperCommand(housekeeperInList), model,
AddHousekeeperCommand.MESSAGE_DUPLICATE_HOUSEKEEPER);
}

}
24 changes: 19 additions & 5 deletions src/test/java/seedu/address/logic/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.BOB;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.function.Predicate;

import org.junit.jupiter.api.Test;
Expand All @@ -27,7 +29,6 @@
import seedu.address.model.person.Person;
import seedu.address.testutil.ClientBuilder;
import seedu.address.testutil.HousekeeperBuilder;
import seedu.address.testutil.PersonBuilder;

public class AddCommandTest {

Expand Down Expand Up @@ -124,8 +125,12 @@ public void equals() {
@Test
public void toStringMethod() {
AddClientCommand addClientCommand = new AddClientCommand(ALICE);
String expected = AddClientCommand.class.getCanonicalName() + "{toAdd=" + ALICE + "}";
assertEquals(expected, addClientCommand.toString());
String expectedOne = AddClientCommand.class.getCanonicalName() + "{toAdd=" + ALICE + "}";
assertEquals(expectedOne, addClientCommand.toString());

AddHousekeeperCommand addHousekeeperCommand = new AddHousekeeperCommand(BOB);
String expectedTwo = AddHousekeeperCommand.class.getCanonicalName() + "{toAdd=" + BOB + "}";
assertEquals(expectedTwo, addHousekeeperCommand.toString());
}

/**
Expand Down Expand Up @@ -223,14 +228,23 @@ public ObservableList<Housekeeper> getFilteredHousekeeperList() {
}

@Override
public void updateFilteredClientList(Predicate<Client> predicate) {
public void updateFilteredClientList(Predicate<? extends Person> predicate) {
throw new AssertionError("This method should not be called.");
}

@Override
public void updateFilteredHousekeeperList(Predicate<? extends Person> predicate) {
throw new AssertionError("This method should not be called.");
}

@Override
public void updateFilteredHousekeeperList(Predicate<Housekeeper> predicate) {
public void updateAndSortFilteredClientList(Predicate<Client> predicate, Comparator<Client> comparator) {
throw new AssertionError("This method should not be called.");
}

@Override
public void updateFilteredHousekeeperListWithHousekeeperPredicate(Predicate<Housekeeper> predicate) {
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ public static void showHousekeeperAtIndex(Model model, Index targetIndex) {

assertEquals(1, model.getFilteredHousekeeperList().size());
}
}
}
Loading

0 comments on commit de5e4b5

Please sign in to comment.