From ff6d9b63bb70d55f8efeb10601ea72cdf8c24c8b Mon Sep 17 00:00:00 2001 From: leeshaowee Date: Wed, 22 Mar 2023 15:32:52 +0800 Subject: [PATCH] Fix checkstyle errors and failed test cases --- .../logic/commands/FindCommandTest.java | 6 ++++-- .../logic/parser/FindCommandParserTest.java | 18 +++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 0f70bcd0bdc..73267389b0b 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -12,6 +12,7 @@ import java.util.function.Predicate; import org.junit.jupiter.api.Test; + import seedu.address.commons.core.Messages; import seedu.address.model.Level; import seedu.address.model.Model; @@ -33,10 +34,11 @@ * Contains integration tests (interaction with the Model) for {@code FindCommand}. */ public class FindCommandTest { + private static final Module CS2040S = TypicalModules.getCs2040s(); + private static final Module ST2334 = TypicalModules.getSt2334(); + private Model model = new ModelManager(getTypicalTracker(), new UserPrefs()); private Model expectedModel = new ModelManager(getTypicalTracker(), new UserPrefs()); - private final static Module CS2040S = TypicalModules.getCs2040s(); - private final static Module ST2334 = TypicalModules.getSt2334(); @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index e36069f999a..e6ffa5cf15e 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -4,6 +4,7 @@ import static seedu.address.logic.commands.CommandTestUtil.INVALID_LECTURE_NAME_DESC; import static seedu.address.logic.commands.CommandTestUtil.INVALID_MODULE_CODE_DESC; import static seedu.address.logic.commands.CommandTestUtil.MODULE_CODE_DESC_2103; +import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY; import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; @@ -11,6 +12,7 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; + import seedu.address.logic.commands.FindCommand; import seedu.address.model.lecture.LectureName; import seedu.address.model.module.ModuleCode; @@ -34,16 +36,18 @@ public void parse_validArgs_returnsFindCommand() { public void parse_invalidArgs_throwsParseException() { String invalidFormat = String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE); - // No empty args + // No empty keywords assertParseFailure(parser, PREAMBLE_WHITESPACE, invalidFormat); - // Missing module code and invalid lecture name format - assertParseFailure(parser, INVALID_LECTURE_NAME_DESC, invalidFormat); + // Keyword present, missing module code and invalid lecture name format + assertParseFailure(parser, PREAMBLE_NON_EMPTY + INVALID_LECTURE_NAME_DESC, invalidFormat); - // Invalid module code format - assertParseFailure(parser, INVALID_MODULE_CODE_DESC, ModuleCode.MESSAGE_CONSTRAINTS); + // Keyword present, invalid module code format + assertParseFailure(parser, PREAMBLE_NON_EMPTY + INVALID_MODULE_CODE_DESC, ModuleCode.MESSAGE_CONSTRAINTS); - // Valid module code present but invalid lecture name format - assertParseFailure(parser, MODULE_CODE_DESC_2103 + INVALID_LECTURE_NAME_DESC, LectureName.MESSAGE_CONSTRAINTS); + // Keyword present, valid module code present but invalid lecture name format + assertParseFailure(parser, + PREAMBLE_NON_EMPTY + MODULE_CODE_DESC_2103 + INVALID_LECTURE_NAME_DESC, + LectureName.MESSAGE_CONSTRAINTS); } }