Skip to content

Commit

Permalink
Merge pull request #269 from e1121208/truly-pushing-the-limits-la-sial
Browse files Browse the repository at this point in the history
Place the final touches to the code coverage
  • Loading branch information
seandias authored Nov 7, 2024
2 parents ad928f6 + 9093a0b commit 832112d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public static String format(Listing listing) {
.append("; Seller: ")
.append(listing.getSeller());
listing.getBuyers().forEach(builder::append);
return builder.toString();
return String.format("%1s.\nAddress: %2s",
listing.getName(), listing.getAddress());
//return builder.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
Expand All @@ -18,15 +19,18 @@

import seedu.address.logic.Messages;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.commands.listingcommands.EditListingCommand.EditListingDescriptor;
import seedu.address.model.Listings;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.listing.Listing;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.testutil.EditListingDescriptorBuilder;
import seedu.address.testutil.ListingBuilder;
import seedu.address.testutil.PersonBuilder;

public class EditListingCommandTest {
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs(), getTypicalListings());
Expand Down Expand Up @@ -177,4 +181,29 @@ public void toStringMethod() {
+ ", editListingDescriptor=" + editListingDescriptor + "}";
assertEquals(expected, editListingCommand.toString());
}
@Test
public void execute_nonSellerSpecified_throwsCommandException() {
Model model = new ModelManager();
Person nonSellerPerson = new PersonBuilder().withName("NonSeller").buildSeller();
model.addPerson(nonSellerPerson);

EditListingCommand.EditListingDescriptor descriptor = new EditListingDescriptorBuilder()
.withName("NonSeller").build();
EditListingCommand command = new EditListingCommand(new Name("SampleListing"), descriptor);

assertThrows(CommandException.class, () -> command.execute(model),
"The specified person is not a seller.");
}

@Test
public void execute_sellerNotFound_throwsCommandException() {
Model model = new ModelManager();

EditListingCommand.EditListingDescriptor descriptor = new EditListingDescriptorBuilder()
.withName("MissingSeller").build();
EditListingCommand command = new EditListingCommand(new Name("SampleListing"), descriptor);

assertThrows(CommandException.class, () -> command.execute(model),
"Seller not found in the system.");
}
}
5 changes: 5 additions & 0 deletions src/test/java/seedu/address/model/appointment/DateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ public void equals() {
otherDate = new Date("131224");
assertFalse(date.equals(otherDate));
}
@Test
public void parseDate_invalidFormat_throwsIllegalArgumentException() {
String invalidDate = "32-12-24";

assertThrows(IllegalArgumentException.class, () -> new Date(invalidDate));
}
}
6 changes: 6 additions & 0 deletions src/test/java/seedu/address/model/appointment/FromTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ public void equals() {
otherDate = new From("0900");
assertFalse(from.equals(otherDate));
}
@Test
public void parseTime_invalidFormat_throwsIllegalArgumentException() {
String invalidTime = "25:00";

assertThrows(IllegalArgumentException.class, () -> new From(invalidTime));
}
}
6 changes: 6 additions & 0 deletions src/test/java/seedu/address/model/appointment/ToTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ public void equals() {
otherDate = new To("0900");
assertFalse(to.equals(otherDate));
}
@Test
public void parseTime_invalidFormat_throwsIllegalArgumentException() {
String invalidTime = "10:64";

assertThrows(IllegalArgumentException.class, () -> new To(invalidTime));
}
}
1 change: 0 additions & 1 deletion src/test/java/seedu/address/ui/CommandBoxUiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void setUp() throws Exception {
FxToolkit.showStage();
WaitForAsyncUtils.waitForFxEvents(20);
}

@AfterEach
public void tearDown() throws TimeoutException {
FxToolkit.cleanupStages();
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/seedu/address/ui/MainWindowUiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.util.WaitForAsyncUtils;

import javafx.scene.control.TextArea;
import javafx.scene.input.KeyCode;
import seedu.address.MainApp;

Expand All @@ -31,4 +32,14 @@ void handleHelp_handlesHelpCommandCorrectly() {
robot.type(KeyCode.ENTER);
assertTrue(robot.lookup("#helpMessage").query().isVisible());
}
@Test
void handleHelp_handlesListingsCommandCorrectly() {
FxRobot robot = new FxRobot();
robot.clickOn("#commandTextField");
robot.write("showlistings");
robot.type(KeyCode.ENTER);
TextArea resultDisplay = robot.lookup("#resultDisplay").query();
assertTrue(resultDisplay.getText().contains("Here are your listings!")
|| resultDisplay.getText().contains("You have no listings available."));
}
}

0 comments on commit 832112d

Please sign in to comment.