From 451ff49615107c65c065f2bd276c0afd09414cef Mon Sep 17 00:00:00 2001 From: Tan Wen Xuan <> Date: Tue, 5 Nov 2024 17:22:13 +0800 Subject: [PATCH 1/3] Improve CommandBoxUiTest test --- .../java/seedu/address/ui/CommandBoxUiTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/seedu/address/ui/CommandBoxUiTest.java b/src/test/java/seedu/address/ui/CommandBoxUiTest.java index 14e31d6bdf4..49632c289ea 100644 --- a/src/test/java/seedu/address/ui/CommandBoxUiTest.java +++ b/src/test/java/seedu/address/ui/CommandBoxUiTest.java @@ -2,6 +2,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static seedu.address.ui.CommandBox.ERROR_STYLE_CLASS; import java.util.ArrayList; import java.util.Arrays; @@ -22,6 +25,7 @@ import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import seedu.address.MainApp; +import seedu.address.logic.commands.exceptions.CommandException; @ExtendWith(ApplicationExtension.class) public class CommandBoxUiTest extends ApplicationTest { @@ -73,4 +77,16 @@ public void commandNavigationWorks_success() { robot.type(KeyCode.DOWN); } } + @Test + public void setStyleToIndicateCommandFailure_addsErrorStyleClass() { + FxRobot robot = new FxRobot(); + + assertNotNull(robot.lookup("#commandTextField"), "Command box should be present."); + + robot.clickOn("#commandTextField"); + robot.write("UNKNOWN COMMMAND"); + robot.type(KeyCode.ENTER); + assertTrue(robot.lookup("#commandTextField").query().getStyleClass().contains(ERROR_STYLE_CLASS)); + } + } From 8af24a8df17714d7cc7d3b5dad8fec8358729f76 Mon Sep 17 00:00:00 2001 From: Tan Wen Xuan <> Date: Tue, 5 Nov 2024 17:33:47 +0800 Subject: [PATCH 2/3] Resolve checkstyle error --- src/test/java/seedu/address/ui/CommandBoxUiTest.java | 3 --- src/test/java/seedu/address/ui/ListingCardUiTest.java | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/test/java/seedu/address/ui/CommandBoxUiTest.java b/src/test/java/seedu/address/ui/CommandBoxUiTest.java index 49632c289ea..023faf31e0b 100644 --- a/src/test/java/seedu/address/ui/CommandBoxUiTest.java +++ b/src/test/java/seedu/address/ui/CommandBoxUiTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.ui.CommandBox.ERROR_STYLE_CLASS; @@ -25,7 +24,6 @@ import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import seedu.address.MainApp; -import seedu.address.logic.commands.exceptions.CommandException; @ExtendWith(ApplicationExtension.class) public class CommandBoxUiTest extends ApplicationTest { @@ -82,7 +80,6 @@ public void setStyleToIndicateCommandFailure_addsErrorStyleClass() { FxRobot robot = new FxRobot(); assertNotNull(robot.lookup("#commandTextField"), "Command box should be present."); - robot.clickOn("#commandTextField"); robot.write("UNKNOWN COMMMAND"); robot.type(KeyCode.ENTER); diff --git a/src/test/java/seedu/address/ui/ListingCardUiTest.java b/src/test/java/seedu/address/ui/ListingCardUiTest.java index 1e50db58ad9..0671db7cdfd 100644 --- a/src/test/java/seedu/address/ui/ListingCardUiTest.java +++ b/src/test/java/seedu/address/ui/ListingCardUiTest.java @@ -44,8 +44,8 @@ public class ListingCardUiTest extends ApplicationTest { private ListingCard listingCard; private Listing sampleListing; private final Seller sampleSeller = (Seller) createSampleSeller(); - private final Buyer sampleBuyer_one = (Buyer) createSampleBuyer_one(); - private final Buyer sampleBuyer_two = (Buyer) createSampleBuyer_two(); + private final Buyer sampleBuyerOne = (Buyer) createSampleBuyer_one(); + private final Buyer sampleBuyerTwo = (Buyer) createSampleBuyer_two(); @BeforeEach @@ -136,8 +136,8 @@ void listingCard_handlesDifferentIndexes() { */ private Listing createSampleListing() { Set buyersSet = new HashSet<>(); - buyersSet.add(sampleBuyer_one); - buyersSet.add(sampleBuyer_two); + buyersSet.add(sampleBuyerOne); + buyersSet.add(sampleBuyerTwo); return new Listing( new Name("Sample Listing"), From b6e169387405c088657cc09449af7a175445d0b3 Mon Sep 17 00:00:00 2001 From: Tan Wen Xuan <> Date: Tue, 5 Nov 2024 17:34:56 +0800 Subject: [PATCH 3/3] Resolve checkstyle error --- src/test/java/seedu/address/ui/ListingCardUiTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/address/ui/ListingCardUiTest.java b/src/test/java/seedu/address/ui/ListingCardUiTest.java index 0671db7cdfd..7e86daeab49 100644 --- a/src/test/java/seedu/address/ui/ListingCardUiTest.java +++ b/src/test/java/seedu/address/ui/ListingCardUiTest.java @@ -44,8 +44,8 @@ public class ListingCardUiTest extends ApplicationTest { private ListingCard listingCard; private Listing sampleListing; private final Seller sampleSeller = (Seller) createSampleSeller(); - private final Buyer sampleBuyerOne = (Buyer) createSampleBuyer_one(); - private final Buyer sampleBuyerTwo = (Buyer) createSampleBuyer_two(); + private final Buyer sampleBuyerOne = (Buyer) createSampleBuyerOne(); + private final Buyer sampleBuyerTwo = (Buyer) createSampleBuyerTwo(); @BeforeEach @@ -170,7 +170,7 @@ private Person createSampleSeller() { /** * Helper method to create a sample Buyer object for testing. */ - private Person createSampleBuyer_one() { + private Person createSampleBuyerOne() { Set tagSet = new HashSet<>(); tagSet.add(new Tag("friends")); tagSet.add(new Tag("colleagues")); @@ -188,7 +188,7 @@ private Person createSampleBuyer_one() { /** * Helper method to create a sample Buyer object for testing. */ - private Person createSampleBuyer_two() { + private Person createSampleBuyerTwo() { Set tagSet = new HashSet<>(); tagSet.add(new Tag("friends"));