Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nixonwidjaja committed Oct 1, 2023
1 parent c11e93f commit 541a63a
Show file tree
Hide file tree
Showing 18 changed files with 362 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_SALARY + "SALARY] "
+ "[" + PREFIX_CLAIM_BUDGET + "CLAIM BUDGET] "
+ "[" + PREFIX_DEPARTMENT + "DEPARTMENT] "
+ "[" + PREFIX_DOB + "BIRTHDATE (YYYY-MM-DD)\n"
+ "[" + PREFIX_DOB + "BIRTHDATE (YYYY-MM-DD)]\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public AddCommand parse(String args) throws ParseException {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS);
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_SALARY, PREFIX_CLAIM_BUDGET, PREFIX_DEPARTMENT, PREFIX_DOB);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/Money.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/
public class Money {

public static final String MESSAGE_CONSTRAINTS = "Dollar amount should be a positive integer " +
"with max value of $1,000,000,000,000";
public static final String MESSAGE_CONSTRAINTS = "Dollar amount should be a positive integer "
+ "with max value of $1,000,000,000,000";
public static final Long MAX_VALUE = (long) 1e12;

public final String amount;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
{
"persons": [ {
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"tags": [ "friends" ]
}, {
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "4th street"
} ]
"persons": [
{
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"salary": "100000",
"claimBudget": "1",
"department": "Finance",
"dob": "2002-02-27"
},
{
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "4th street",
"salary": "100000",
"claimBudget": "1",
"department": "Finance",
"dob": "2002-02-27"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,46 +1,75 @@
{
"_comment": "AddressBook save file which contains the same Person values as in TypicalPersons#getTypicalAddressBook()",
"persons" : [ {
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"address" : "123, Jurong West Ave 6, #08-111",
"tags" : [ "friends" ]
}, {
"name" : "Benson Meier",
"phone" : "98765432",
"email" : "[email protected]",
"address" : "311, Clementi Ave 2, #02-25",
"tags" : [ "owesMoney", "friends" ]
}, {
"name" : "Carl Kurz",
"phone" : "95352563",
"email" : "[email protected]",
"address" : "wall street",
"tags" : [ ]
}, {
"name" : "Daniel Meier",
"phone" : "87652533",
"email" : "[email protected]",
"address" : "10th street",
"tags" : [ "friends" ]
}, {
"name" : "Elle Meyer",
"phone" : "9482224",
"email" : "[email protected]",
"address" : "michegan ave",
"tags" : [ ]
}, {
"name" : "Fiona Kunz",
"phone" : "9482427",
"email" : "[email protected]",
"address" : "little tokyo",
"tags" : [ ]
}, {
"name" : "George Best",
"phone" : "9482442",
"email" : "[email protected]",
"address" : "4th street",
"tags" : [ ]
} ]
"persons": [
{
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"salary": "10000",
"claimBudget": "5000",
"department": "Engineering",
"dob": "2000-01-01"
},
{
"name": "Benson Meier",
"phone": "98765432",
"email": "[email protected]",
"address": "311, Clementi Ave 2, #02-25",
"salary": "100",
"claimBudget": "5",
"department": "Sales",
"dob": "1997-05-05"
},
{
"name": "Carl Kurz",
"phone": "95352563",
"email": "[email protected]",
"address": "wall street",
"salary": "1000000000000",
"claimBudget": "500000",
"department": "Executive",
"dob": "1991-12-31"
},
{
"name": "Daniel Meier",
"phone": "87652533",
"email": "[email protected]",
"address": "10th street",
"salary": "23232323232",
"claimBudget": "19191919",
"department": "Marketing",
"dob": "1969-07-27"
},
{
"name": "Elle Meyer",
"phone": "9482224",
"email": "[email protected]",
"address": "michegan ave",
"salary": "3000",
"claimBudget": "200",
"department": "HR",
"dob": "1999-06-17"
},
{
"name": "Fiona Kunz",
"phone": "9482427",
"email": "[email protected]",
"address": "little tokyo",
"salary": "100000",
"claimBudget": "1",
"department": "Finance",
"dob": "2002-02-27"
},
{
"name": "George Best",
"phone": "9482442",
"email": "[email protected]",
"address": "4th street",
"salary": "10000",
"claimBudget": "5000",
"department": "Engineering",
"dob": "2005-09-30"
}
]
}
10 changes: 7 additions & 3 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;
import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.BUDGET_DESC;
import static seedu.address.logic.commands.CommandTestUtil.DEPARTMENT_DESC;
import static seedu.address.logic.commands.CommandTestUtil.DOB_DESC;
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.SALARY_DESC;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPersons.AMY;

Expand Down Expand Up @@ -165,9 +169,9 @@ 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 + NAME_DESC_AMY + PHONE_DESC_AMY
+ EMAIL_DESC_AMY + ADDRESS_DESC_AMY;
Person expectedPerson = new PersonBuilder(AMY).withTags().build();
String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY
+ ADDRESS_DESC_AMY + SALARY_DESC + BUDGET_DESC + DEPARTMENT_DESC + DOB_DESC;
Person expectedPerson = new PersonBuilder(AMY).build();
ModelManager expectedModel = new ModelManager();
expectedModel.addPerson(expectedPerson);
assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel);
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/seedu/address/logic/commands/CommandTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CLAIM_BUDGET;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEPARTMENT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DOB;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.testutil.Assert.assertThrows;

Expand Down Expand Up @@ -34,6 +38,10 @@ public class CommandTestUtil {
public static final String VALID_EMAIL_BOB = "[email protected]";
public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1";
public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3";
public static final String VALID_SALARY = "10000";
public static final String VALID_BUDGET = "2500";
public static final String VALID_DEPARTMENT = "Engineering";
public static final String VALID_DOB = "2000-01-01";
public static final String VALID_TAG_HUSBAND = "husband";
public static final String VALID_TAG_FRIEND = "friend";

Expand All @@ -45,10 +53,14 @@ public class CommandTestUtil {
public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB;
public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY;
public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB;
public static final String SALARY_DESC = " " + PREFIX_SALARY + VALID_SALARY;
public static final String BUDGET_DESC = " " + PREFIX_CLAIM_BUDGET + VALID_BUDGET;
public static final String DEPARTMENT_DESC = " " + PREFIX_DEPARTMENT + VALID_DEPARTMENT;
public static final String DOB_DESC = " " + PREFIX_DOB + VALID_DOB;
public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND;
public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND;

public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names
public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + " "; // blank not allowed in names
public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones
public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol
public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -51,10 +50,6 @@ public void equals() {
// different address -> returns false
editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withAddress(VALID_ADDRESS_BOB).build();
assertFalse(DESC_AMY.equals(editedAmy));

// different tags -> returns false
editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build();
assertFalse(DESC_AMY.equals(editedAmy));
}

@Test
Expand All @@ -64,8 +59,11 @@ public void toStringMethod() {
+ editPersonDescriptor.getName().orElse(null) + ", phone="
+ editPersonDescriptor.getPhone().orElse(null) + ", email="
+ editPersonDescriptor.getEmail().orElse(null) + ", address="
+ editPersonDescriptor.getAddress().orElse(null) + ", tags="
+ editPersonDescriptor.getTags().orElse(null) + "}";
+ editPersonDescriptor.getAddress().orElse(null) + ", salary="
+ editPersonDescriptor.getSalary().orElse(null) + ", claimBudget="
+ editPersonDescriptor.getClaimBudget().orElse(null) + ", department="
+ editPersonDescriptor.getDepartment().orElse(null) + ", dob="
+ editPersonDescriptor.getDob().orElse(null) + "}";
assertEquals(expected, editPersonDescriptor.toString());
}
}
Loading

0 comments on commit 541a63a

Please sign in to comment.