Skip to content

Commit

Permalink
Fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
NereusWB922 committed Oct 30, 2023
1 parent fe50a33 commit b4aed85
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void setup() {

@Test
public void constructor_nullArgs_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new CreateDeadlineCommand(null, null));
assertThrows(NullPointerException.class, () -> new CreateDeadlineCommand(null, null, null));
}

@Test
Expand All @@ -60,7 +60,7 @@ public void execute_deadlineForStudentAccepted_addSuccessful() throws InvalidPat
TaskOperation operation = expectedModel.taskOperation(absoluteTargetPath);
operation.addTask(toBeAdded);

CreateDeadlineCommand command = new CreateDeadlineCommand(absoluteTargetPath, toBeAdded);
CreateDeadlineCommand command = new CreateDeadlineCommand(absoluteTargetPath, toBeAdded, Category.NONE);
String expectedMessage = String.format(CreateDeadlineCommand.MESSAGE_SUCCESS,
toBeAdded);

Expand All @@ -78,7 +78,7 @@ public void execute_deadlineForAllStudentsInGroupAccepted_addSuccessful()
ChildOperation<Student> operation = expectedModel.groupChildOperation(absoluteTargetPath);
operation.addTaskToAllChildren(toBeAdded, 1);

CreateDeadlineCommand command = new CreateDeadlineCommand(absoluteTargetPath, toBeAdded, "allStu");
CreateDeadlineCommand command = new CreateDeadlineCommand(absoluteTargetPath, toBeAdded, Category.ALLSTU);
String expectedMessage = CreateDeadlineCommand.MESSAGE_SUCCESS_ALL_STUDENTS;

assertCommandSuccess(command, model, expectedMessage, expectedModel);
Expand All @@ -90,7 +90,7 @@ public void execute_deadlineForAllGroupsInRootAccepted_addSuccessful()
ChildOperation<Group> operation = expectedModel.rootChildOperation();
operation.addTaskToAllChildren(toBeAdded, 1);

CreateDeadlineCommand command = new CreateDeadlineCommand(rootPath, toBeAdded, "allGrp");
CreateDeadlineCommand command = new CreateDeadlineCommand(rootPath, toBeAdded, Category.ALLGRP);
String expectedMessage = CreateDeadlineCommand.MESSAGE_SUCCESS_ALL_GROUPS;

assertCommandSuccess(command, model, expectedMessage, expectedModel);
Expand All @@ -109,22 +109,25 @@ public void execute_duplicateDeadline_throwsCommandException() throws InvalidPat
TaskOperation operation = model.taskOperation(absoluteTargetPath);
operation.addTask(toBeAdded);

CreateDeadlineCommand command = new CreateDeadlineCommand(absoluteTargetPath, toBeAdded);
CreateDeadlineCommand command = new CreateDeadlineCommand(absoluteTargetPath, toBeAdded, Category.NONE);
String expectedMessage = CreateDeadlineCommand.MESSAGE_DUPLICATE_DEADLINE_TASK;

assertCommandFailure(command, model, expectedMessage);
}

@Test
public void equals() {
CreateDeadlineCommand createDeadlineCommand1 = new CreateDeadlineCommand(rootPath, TypicalTasks.DEADLINE_1);
CreateDeadlineCommand createDeadlineCommand2 = new CreateDeadlineCommand(rootPath, TypicalTasks.DEADLINE_2);
CreateDeadlineCommand createDeadlineCommand1 = new CreateDeadlineCommand(
rootPath, TypicalTasks.DEADLINE_1, Category.NONE);
CreateDeadlineCommand createDeadlineCommand2 = new CreateDeadlineCommand(
rootPath, TypicalTasks.DEADLINE_2, Category.NONE);

// same object -> returns true
assertEquals(createDeadlineCommand1, createDeadlineCommand1);

// same values -> returns true
CreateDeadlineCommand createDeadlineCommand1Copy = new CreateDeadlineCommand(rootPath, TypicalTasks.DEADLINE_1);
CreateDeadlineCommand createDeadlineCommand1Copy = new CreateDeadlineCommand(
rootPath, TypicalTasks.DEADLINE_1, Category.NONE);
assertEquals(createDeadlineCommand1, createDeadlineCommand1Copy);

// different types -> returns false
Expand All @@ -139,7 +142,8 @@ public void equals() {

@Test
public void toStringMethod() {
CreateDeadlineCommand createDeadlineCommand = new CreateDeadlineCommand(rootPath, TypicalTasks.DEADLINE_1);
CreateDeadlineCommand createDeadlineCommand = new CreateDeadlineCommand(
rootPath, TypicalTasks.DEADLINE_1, Category.NONE);
String expected = CreateDeadlineCommand.class.getCanonicalName()
+ "{toCreateDeadline=" + TypicalTasks.DEADLINE_1 + "}";
assertEquals(expected, createDeadlineCommand.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void setup() {

@Test
public void constructor_nullRelativePathAndTodo_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new CreateTodoCommand(null, null));
assertThrows(NullPointerException.class, () -> new CreateTodoCommand(null, null, null));
}

@Test
Expand All @@ -62,7 +62,7 @@ public void execute_todoForAllStudentsInGroupAccepted_addSuccessful()
ChildOperation<Student> operation = expectedModel.groupChildOperation(absoluteTargetPath);
operation.addTaskToAllChildren(toBeAdded, 1);

CreateTodoCommand command = new CreateTodoCommand(absoluteTargetPath, toBeAdded, "allStu");
CreateTodoCommand command = new CreateTodoCommand(absoluteTargetPath, toBeAdded, Category.ALLSTU);
String expectedMessage = MESSAGE_SUCCESS_ALL_STUDENTS;

assertCommandSuccess(command, model, expectedMessage, expectedModel);
Expand All @@ -74,7 +74,7 @@ public void execute_deadlineForAllGroupsInRootAccepted_addSuccessful()
ChildOperation<Group> operation = expectedModel.rootChildOperation();
operation.addTaskToAllChildren(toBeAdded, 1);

CreateTodoCommand command = new CreateTodoCommand(rootPath, toBeAdded, "allGrp");
CreateTodoCommand command = new CreateTodoCommand(rootPath, toBeAdded, Category.ALLGRP);
String expectedMessage = MESSAGE_SUCCESS_ALL_GROUPS;

assertCommandSuccess(command, model, expectedMessage, expectedModel);
Expand All @@ -94,7 +94,7 @@ public void execute_createTodoTask_success() throws CommandException, InvalidPat
TaskOperation operation = expectedModel.taskOperation(absoluteTargetPath);
operation.addTask(toBeAdded);

CreateTodoCommand command = new CreateTodoCommand(absoluteTargetPath, toBeAdded);
CreateTodoCommand command = new CreateTodoCommand(absoluteTargetPath, toBeAdded, Category.NONE);
String expectedMessage = String.format(MESSAGE_SUCCESS, absoluteTargetPath);

assertCommandSuccess(command, model, expectedMessage, expectedModel);
Expand All @@ -114,22 +114,22 @@ public void execute_duplicateTodoTask_throwCommandException() throws InvalidPath
TaskOperation operation = model.taskOperation(absoluteTargetPath);
operation.addTask(toBeAdded);

CreateTodoCommand command = new CreateTodoCommand(absoluteTargetPath, toBeAdded);
CreateTodoCommand command = new CreateTodoCommand(absoluteTargetPath, toBeAdded, Category.NONE);
String expectedMessage = MESSAGE_DUPLICATE_TODO_TASK_STUDENT;

assertCommandFailure(command, model, expectedMessage);
}

@Test
public void equals() {
CreateTodoCommand createTodoCommand1 = new CreateTodoCommand(rootPath, TODO_1);
CreateTodoCommand createTodoCommand2 = new CreateTodoCommand(rootPath, TODO_2);
CreateTodoCommand createTodoCommand1 = new CreateTodoCommand(rootPath, TODO_1, Category.NONE);
CreateTodoCommand createTodoCommand2 = new CreateTodoCommand(rootPath, TODO_2, Category.NONE);

// same object -> returns true
assertEquals(createTodoCommand1, createTodoCommand1);

// same values -> returns true
CreateTodoCommand createDeadlineCommand1Copy = new CreateTodoCommand(rootPath, TODO_1);
CreateTodoCommand createDeadlineCommand1Copy = new CreateTodoCommand(rootPath, TODO_1, Category.NONE);
assertEquals(createTodoCommand1, createDeadlineCommand1Copy);

// different types -> returns false
Expand All @@ -144,7 +144,7 @@ public void equals() {

@Test
public void toStringMethod() {
CreateTodoCommand createDeadlineCommand = new CreateTodoCommand(rootPath, TODO_1);
CreateTodoCommand createDeadlineCommand = new CreateTodoCommand(rootPath, TODO_1, Category.NONE);
String expected = CreateTodoCommand.class.getCanonicalName()
+ "{toCreateTodo=" + TODO_1 + "}";
assertEquals(expected, createDeadlineCommand.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.junit.jupiter.api.Test;

import seedu.address.logic.commands.Category;
import seedu.address.logic.commands.CommandTestUtil;
import seedu.address.logic.commands.CreateDeadlineCommand;
import seedu.address.model.task.Deadline;
Expand All @@ -23,7 +24,8 @@ public void parse_allFieldsPresent_success() {
CommandTestUtil.getValidRootAbsolutePath(),
new CreateDeadlineCommand(
CommandTestUtil.getValidGroupAbsolutePath(),
new Deadline(VALID_TASK_DESC, CommandTestUtil.getValidDateTime())));
new Deadline(VALID_TASK_DESC, CommandTestUtil.getValidDateTime()),
Category.NONE));
}

@Test
Expand All @@ -33,6 +35,7 @@ public void parse_allFieldsPresentWithCategory_success() {
CommandTestUtil.getValidRootAbsolutePath(),
new CreateDeadlineCommand(
CommandTestUtil.getValidGroupAbsolutePath(),
new Deadline(VALID_TASK_DESC, CommandTestUtil.getValidDateTime()), "allStu"));
new Deadline(VALID_TASK_DESC, CommandTestUtil.getValidDateTime()),
Category.ALLSTU));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.junit.jupiter.api.Test;

import seedu.address.logic.commands.Category;
import seedu.address.logic.commands.CommandTestUtil;
import seedu.address.logic.commands.CreateTodoCommand;
import seedu.address.model.task.ToDo;
Expand All @@ -20,7 +21,8 @@ public void parse_allFieldsPresent_success() {
assertParseSuccess(parser,
VALID_STUDENT_DIR_PREAMBLE + TASK_DESC_DESC,
CommandTestUtil.getValidRootAbsolutePath(),
new CreateTodoCommand(CommandTestUtil.getValidStudentAbsolutePath(), new ToDo(VALID_TASK_DESC)));
new CreateTodoCommand(CommandTestUtil.getValidStudentAbsolutePath(), new ToDo(VALID_TASK_DESC),
Category.NONE));
}

@Test
Expand All @@ -29,6 +31,7 @@ public void parse_allFieldsPresentWithCatergory_success() {
VALID_STUDENT_DIR_PREAMBLE + TASK_DESC_DESC + VALID_CATEGORY_STUDENT,
CommandTestUtil.getValidRootAbsolutePath(),
new CreateTodoCommand(CommandTestUtil.getValidStudentAbsolutePath(),
new ToDo(VALID_TASK_DESC), "allStu"));
new ToDo(VALID_TASK_DESC),
Category.ALLSTU));
}
}

0 comments on commit b4aed85

Please sign in to comment.