Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test date #13198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/test/java/teammates/logic/core/FeedbackSessionsLogicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,77 @@ 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));

// 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
));
}


@Test
public void testDeleteFeedbackSessionsDeadlinesForStudent() {
StudentAttributes student4InCourse1 = dataBundle.students.get("student4InCourse1");
Expand Down
Loading