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 test cases in AddClientCommandParserTest #290

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"address" : "10th street",
"birthday" : "",
"meetings" : [ ],
"products" : [ "friends" ]
"products" : [ "Product2" ]
}, {
"@UUID" : "deed0742-5740-4514-87e7-bd9bef479046",
"name" : "Elle Meyer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_PRODUCT_DESC;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY;
Expand All @@ -34,6 +35,7 @@
import seedu.address.model.client.Email;
import seedu.address.model.client.Name;
import seedu.address.model.client.Phone;
import seedu.address.model.product.Product;
import seedu.address.testutil.ClientBuilder;

public class AddClientCommandParserTest {
Expand Down Expand Up @@ -113,6 +115,10 @@ public void parse_invalidValue_failure() {
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC
+ PRODUCT_DESC_PRODUCT2 + PRODUCT_DESC_PRODUCT1, Address.MESSAGE_CONSTRAINTS);

// invalid product
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ INVALID_PRODUCT_DESC + PRODUCT_DESC_PRODUCT1, Product.MESSAGE_CONSTRAINTS);

// two invalid values, only first invalid value reported
assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC,
Name.MESSAGE_CONSTRAINTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

public class EditCommandParserTest {

private static final String Product_EMPTY = " " + PREFIX_PRODUCT;
private static final String PRODUCT_EMPTY = " " + PREFIX_PRODUCT;

private static final String MESSAGE_INVALID_FORMAT =
String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditClientCommand.MESSAGE_USAGE);
Expand Down Expand Up @@ -94,6 +94,15 @@ public void parse_invalidValue_failure() {
// is tested at {@code parse_invalidValueFollowedByValidValue_success()}
assertParseFailure(parser, " i/1" + PHONE_DESC_BOB + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS);

// while parsing {@code PREFIX_PRODUCT} alone will reset the products of the {@code Client} being edited,
// parsing it together with a valid product results in error
assertParseFailure(parser, " i/1" + PRODUCT_DESC_PRODUCT1 + PRODUCT_DESC_PRODUCT2 + PRODUCT_EMPTY,
Product.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, " i/1" + PRODUCT_DESC_PRODUCT1 + PRODUCT_EMPTY + PRODUCT_DESC_PRODUCT2,
Product.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, " i/1" + PRODUCT_EMPTY + PRODUCT_DESC_PRODUCT1 + PRODUCT_DESC_PRODUCT2,
Product.MESSAGE_CONSTRAINTS);

// multiple invalid values, but only the first invalid value is captured
assertParseFailure(parser, " i/1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC
+ VALID_ADDRESS_AMY + VALID_PHONE_AMY, Name.MESSAGE_CONSTRAINTS);
Expand Down Expand Up @@ -195,7 +204,7 @@ public void parse_invalidValueFollowedByValidValue_success() {
@Test
public void parse_resetProducts_success() {
Index targetIndex = INDEX_THIRD_ELEMENT;
String userInput = " i/" + targetIndex.getOneBased() + Product_EMPTY;
String userInput = " i/" + targetIndex.getOneBased() + PRODUCT_EMPTY;

EditClientDescriptor descriptor = new EditClientDescriptorBuilder().withProducts().build();
EditClientCommand expectedCommand = new EditClientCommand(targetIndex, descriptor);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/testutil/TypicalClients.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TypicalClients {
.withEmail("heinz@example.com").withAddress("wall street")
.build();
public static final Client DANIEL = new ClientBuilder().withName("Daniel Meier").withPhone("87652533")
.withEmail("cornelia@example.com").withAddress("10th street").withProducts("friends").build();
.withEmail("cornelia@example.com").withAddress("10th street").withProducts("Product2").build();
public static final Client ELLE = new ClientBuilder().withName("Elle Meyer").withPhone("94822241")
.withEmail("werner@example.com").withAddress("michegan ave").build();
public static final Client FIONA = new ClientBuilder().withName("Fiona Kunz").withPhone("94824271")
Expand Down