Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103T-T09-2#249 from emzm2023/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
mingyu-wan authored Nov 13, 2023
2 parents 201a102 + 800d946 commit 71487c1
Show file tree
Hide file tree
Showing 23 changed files with 1,073 additions and 145 deletions.
1 change: 1 addition & 0 deletions ClientRoles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions DeveloperRoles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean equals(Object other) {
}

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

Expand Down
38 changes: 36 additions & 2 deletions src/test/java/seedu/address/logic/commands/CommandTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.edit.EditClientCommand;
import seedu.address.logic.commands.edit.EditDeveloperCommand;
import seedu.address.logic.commands.edit.EditProjectCommand;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.client.Client;
import seedu.address.model.client.NameClientContainsKeywordsPredicate;
import seedu.address.model.developer.Developer;
import seedu.address.model.developer.NameDeveloperContainsKeywordsPredicate;
import seedu.address.model.project.Project;
import seedu.address.model.project.ProjectNameContainsKeywordsPredicate;
import seedu.address.testutil.EditClientDescriptorBuilder;
import seedu.address.testutil.EditDeveloperDescriptorBuilder;
import seedu.address.testutil.EditProjectDescriptorBuilder;

/**
* Contains helper methods for testing commands.
Expand Down Expand Up @@ -71,6 +75,7 @@ public class CommandTestUtil {
public static final String VALID_PROJECT_2_AMY = "ProjectB";
public static final String VALID_PROJECT_1_BOB = "ProjectC";
public static final String VALID_PROJECT_2_BOB = "ProjectD";
public static final String VALID_PROJECT_3_BOB = "Project C";
public static final String VALID_PROJECT_1_CALEB = "ProjectC";
public static final String VALID_PROJECT_2_CALEB = "ProjectD";
public static final String VALID_PROJECT_1_DAN = "ProjectA";
Expand Down Expand Up @@ -128,7 +133,9 @@ public class CommandTestUtil {
public static final String VALID_PROJECT_DESCRIPTION_APPLEAPP = "Developing the AppleApp";
public static final String VALID_PROJECT_DESCRIPTION_GOOGLEAPP = "Working on the GoogleApp";
public static final String VALID_PROJECT_DESCRIPTION_ANDROIDAPP = "AndroidApp development";

public static final String VALID_FULL_PROJECT_DEADLINE_1 = "31-12-2019,Develop front end interface,HIGH,0";
public static final String VALID_FULL_PROJECT_DEADLINE_2 = "01-02-2020,Develop back end,HIGH,0";
public static final String INVALID_FULL_PROJECT_DEADLINE_1 = "30-02-2020,Develop back end,HIGH,0";
public static final String VALID_PROJECT_DEADLINE_APPLEAPP = "2023-12-31";
public static final String VALID_PROJECT_DEADLINE_GOOGLEAPP = "2023-11-30";
public static final String VALID_PROJECT_DEADLINE_ANDROIDAPP = "2023-10-31";
Expand Down Expand Up @@ -164,6 +171,8 @@ public class CommandTestUtil {
public static final EditDeveloperCommand.EditDeveloperDescriptor DESC_BOB;
public static final EditClientCommand.EditClientDescriptor DESC_CALEB;
public static final EditClientCommand.EditClientDescriptor DESC_DAN;
public static final EditProjectCommand.EditProjectDescriptor DESC_PROJECT1;
public static final EditProjectCommand.EditProjectDescriptor DESC_PROJECT2;


static {
Expand All @@ -183,6 +192,10 @@ public class CommandTestUtil {
.withAddress(VALID_ADDRESS_DAN).withEmail(VALID_EMAIL_DAN).withProjects(VALID_PROJECT_1_DAN)
.withDocument(VALID_DOCUMENT_DAN).build();

DESC_PROJECT1 = new EditProjectDescriptorBuilder().withDescription(VALID_PROJECT_DESCRIPTION_ANDROIDAPP)
.withDeadlines(VALID_FULL_PROJECT_DEADLINE_1).build();
DESC_PROJECT2 = new EditProjectDescriptorBuilder().withDescription(VALID_PROJECT_DESCRIPTION_APPLEAPP)
.withDeadlines(VALID_FULL_PROJECT_DEADLINE_2).build();
}

/**
Expand Down Expand Up @@ -233,7 +246,16 @@ public static void assertClientCommandSuccess(Command command, Model actualModel
assertCommandSuccess(command, actualModel, expectedCommandResult, expectedModel);
}


/**
* Convenience wrapper to {@link #assertCommandSuccess(Command, Model, CommandResult, Model)}
* that takes a string {@code expectedMessage}.
*/
public static void assertDeveloperCommandSuccess(Command command, Model actualModel, String expectedMessage,
Model expectedModel) {
CommandResult expectedCommandResult = new CommandResult(expectedMessage, false,
false, TabIndex.Developer);
assertCommandSuccess(command, actualModel, expectedCommandResult, expectedModel);
}


/**
Expand Down Expand Up @@ -282,4 +304,16 @@ public static void showClientAtIndex(Model model, Index targetIndex) {
assertEquals(1, model.getFilteredClientList().size());
}

/**
* Updates {@code model}'s filtered list to show only the project at the given {@code targetIndex} in the
* {@code model}'s address book.
*/
public static void showProjectAtIndex(Model model, Index targetIndex) {
assertTrue(targetIndex.getZeroBased() < model.getFilteredProjectList().size());

Project project = model.getFilteredProjectList().get(targetIndex.getZeroBased());
final String[] splitName = project.getName().split("\\s+");
model.updateFilteredProjectList(new ProjectNameContainsKeywordsPredicate(Arrays.asList(splitName[0])));
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package seedu.address.logic.commands.add;
package seedu.address.logic.commands;

import java.nio.file.Path;
import java.util.function.Predicate;

import javafx.collections.ObservableList;
import seedu.address.commons.core.GuiSettings;
import seedu.address.logic.commands.TabIndex;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import seedu.address.logic.Messages;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.ModelStub;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import seedu.address.logic.Messages;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.ModelStub;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
Expand Down
Loading

0 comments on commit 71487c1

Please sign in to comment.