From 4f80e1e2f23177c7c0d93c9fa15c4f3af913f934 Mon Sep 17 00:00:00 2001 From: Pluiexo Date: Fri, 15 Mar 2024 10:36:15 +0800 Subject: [PATCH] Add more junit test --- src/main/java/staffconnect/model/meeting/Meeting.java | 1 + .../java/staffconnect/model/meeting/DescriptionTest.java | 4 ++++ .../java/staffconnect/model/meeting/MeetDateTimeTest.java | 4 ++++ src/test/java/staffconnect/model/meeting/MeetingTest.java | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/src/main/java/staffconnect/model/meeting/Meeting.java b/src/main/java/staffconnect/model/meeting/Meeting.java index e9bc83544e0..899db8d3b0f 100644 --- a/src/main/java/staffconnect/model/meeting/Meeting.java +++ b/src/main/java/staffconnect/model/meeting/Meeting.java @@ -18,6 +18,7 @@ public class Meeting { * Constructs a {@code Meeting}. * * @param description A valid meeting description. + * @param startDate A valid time and date for the meeting. */ public Meeting(Description description, MeetDateTime startDate) { diff --git a/src/test/java/staffconnect/model/meeting/DescriptionTest.java b/src/test/java/staffconnect/model/meeting/DescriptionTest.java index 22d0542b0a0..19619d9531f 100644 --- a/src/test/java/staffconnect/model/meeting/DescriptionTest.java +++ b/src/test/java/staffconnect/model/meeting/DescriptionTest.java @@ -46,6 +46,7 @@ public void isValidDescription() { @Test public void equals() { Description description = new Description("Valid Description"); + MeetDateTime testDate = new MeetDateTime("12/04/2023 12:00"); // same values -> returns true assertEquals(description, new Description("Valid Description")); @@ -59,6 +60,9 @@ public void equals() { // different types -> returns false assertNotEquals(5.0f, description); + //Different object type -> returns false + assertFalse(description.equals(testDate)); + // different values -> returns false assertNotEquals(description, new Name("Other valid description")); } diff --git a/src/test/java/staffconnect/model/meeting/MeetDateTimeTest.java b/src/test/java/staffconnect/model/meeting/MeetDateTimeTest.java index 40c38a0eeea..7819dcdb2bb 100644 --- a/src/test/java/staffconnect/model/meeting/MeetDateTimeTest.java +++ b/src/test/java/staffconnect/model/meeting/MeetDateTimeTest.java @@ -48,6 +48,7 @@ public void isValidMeetDate() { @Test public void equals() { MeetDateTime date = new MeetDateTime("20/01/2023 12:00"); + Description testDescription = new Description("Valid Description"); // same values -> returns true assertEquals(date, new MeetDateTime("20/01/2023 12:00")); @@ -61,6 +62,9 @@ public void equals() { // different types -> returns false assertNotEquals(1234, date); + //Different object type -> returns false + assertFalse(date.equals(testDescription)); + // different values -> returns false assertNotEquals(date, new MeetDateTime("15/02/2024 12:00")); } diff --git a/src/test/java/staffconnect/model/meeting/MeetingTest.java b/src/test/java/staffconnect/model/meeting/MeetingTest.java index 0d1749f5ef5..11d1b4086b0 100644 --- a/src/test/java/staffconnect/model/meeting/MeetingTest.java +++ b/src/test/java/staffconnect/model/meeting/MeetingTest.java @@ -1,6 +1,7 @@ package staffconnect.model.meeting; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; import org.junit.jupiter.api.Test; @@ -17,6 +18,8 @@ public void equals() { Meeting testMeeting = new Meeting(testDescription, testDate); Meeting diffMeetingDescription = new Meeting(otherDescription, testDate); Meeting diffMeetingTime = new Meeting(testDescription, otherDate); + MeetDateTime testDate = new MeetDateTime("12/04/2023 12:00"); + // same values -> returns true assertEquals(testMeeting, new Meeting(new Description("Valid description"), @@ -31,6 +34,9 @@ public void equals() { // different type -> returns false assertNotEquals(5, testMeeting); + //Different object type -> returns false + assertFalse(testMeeting.equals(testDate)); + // different description -> returns false assertNotEquals(testMeeting, diffMeetingDescription);