From 9b7cf56c1ae0e2a0f16d6463623fed6b5da3812b Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 17 Jan 2025 23:14:42 -0300 Subject: [PATCH 1/2] test: Test isValidStartEndDate --- .../logic/core/FeedbackSessionsLogicTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java b/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java index 20873caca9f..6fb6582765d 100644 --- a/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java +++ b/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java @@ -844,6 +844,34 @@ public void testDeleteFeedbackSessionsDeadlinesForInstructor() { assertEquals(expectedSessionsDeadlineCounts, newSessionsDeadlineCounts); } + @Test + public void testIsValidStartEndDate() { + FeedbackSessionsLogic logic = FeedbackSessionsLogic.inst(); + ZoneId timeZone = ZoneId.of("UTC"); + + // CT1: TestNullStartDate + assertFalse(logic.isValidStartEndDate(null, Instant.parse("2023-12-31T23:59:59Z"), timeZone)); + + // CT2: TestNullEndDate + assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), null, timeZone)); + + // CT3: TestNullTimeZone + assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"), null)); + + // CT4: TestValidDates + assertTrue(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"), timeZone)); + + // CT5: TestStartDateAfterEndDate + assertFalse(logic.isValidStartEndDate(Instant.parse("2023-12-31T23:59:59Z"), Instant.parse("2023-01-01T00:00:00Z"), timeZone)); + + // CT6: TestStartYearBefore1970 + assertFalse(logic.isValidStartEndDate(Instant.parse("1969-12-31T23:59:59Z"), Instant.parse("2023-12-31T23:59:59Z"), timeZone)); + + // CT7: TestEndYearAfter9999 + assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("10000-01-01T00:00:00Z"), timeZone)); + } + + @Test public void testDeleteFeedbackSessionsDeadlinesForStudent() { StudentAttributes student4InCourse1 = dataBundle.students.get("student4InCourse1"); From e26066bb24af128de1f701d8e47c048c7dc93424 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Fri, 17 Jan 2025 23:27:12 -0300 Subject: [PATCH 2/2] test: Test ValidDate --- .../logic/core/FeedbackSessionsLogicTest.java | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java b/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java index 6fb6582765d..c404e36987f 100644 --- a/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java +++ b/src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java @@ -845,9 +845,10 @@ public void testDeleteFeedbackSessionsDeadlinesForInstructor() { } @Test - public void testIsValidStartEndDate() { + public void testIsValidStartEndDate() { FeedbackSessionsLogic logic = FeedbackSessionsLogic.inst(); ZoneId timeZone = ZoneId.of("UTC"); + // CT1: TestNullStartDate assertFalse(logic.isValidStartEndDate(null, Instant.parse("2023-12-31T23:59:59Z"), timeZone)); @@ -869,6 +870,48 @@ public void testIsValidStartEndDate() { // CT7: TestEndYearAfter9999 assertFalse(logic.isValidStartEndDate(Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("10000-01-01T00:00:00Z"), timeZone)); + + // CT8: TestStartDateEqualEndDate + assertFalse(logic.isValidStartEndDate( + Instant.parse("2023-01-01T00:00:00Z"), + Instant.parse("2023-01-01T00:00:00Z"), + timeZone + )); + + // CT9: TestStartDateJustBeforeEndDate + assertTrue(logic.isValidStartEndDate( + Instant.parse("2023-01-01T00:00:00Z"), + Instant.parse("2023-01-01T00:00:01Z"), + timeZone + )); + + // CT10: TestStartYear1970 + assertTrue(logic.isValidStartEndDate( + Instant.parse("1970-01-01T00:00:00Z"), + Instant.parse("2023-12-31T23:59:59Z"), + timeZone + )); + + // CT11: TestEndYear9999 + assertTrue(logic.isValidStartEndDate( + Instant.parse("2023-01-01T00:00:00Z"), + Instant.parse("9999-12-31T23:59:59Z"), + timeZone + )); + + // CT12: TestStartYearJustBefore1970 + assertFalse(logic.isValidStartEndDate( + Instant.parse("1969-12-31T23:59:59Z"), + Instant.parse("2023-12-31T23:59:59Z"), + timeZone + )); + + // CT13: TestEndYearJustAfter9999 + assertFalse(logic.isValidStartEndDate( + Instant.parse("2023-01-01T00:00:00Z"), + Instant.parse("10000-01-01T00:00:00Z"), + timeZone + )); }