From bc1026a6b78b48cb58128cc410ebba5191f9b632 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 27 Apr 2022 11:40:54 +0200 Subject: [PATCH] SEBSERV-299 fixed for null end-time and added Mockup test quiz11 --- .../servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java | 7 +++++++ .../servicelayer/session/impl/ExamSessionControlTask.java | 2 +- .../webservice/integration/api/admin/QuizDataTest.java | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java index ec71bb8e..0efaf594 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockupLmsAPITemplate.java @@ -130,6 +130,13 @@ public class MockupLmsAPITemplate implements LmsAPITemplate { DateTime.now(DateTimeZone.UTC).plus(6 * Constants.MINUTE_IN_MILLIS) .toString(Constants.DEFAULT_DATE_TIME_FORMAT), "http://lms.mockup.com/api/")); + this.mockups.add(new QuizData( + "quiz11", institutionId, lmsSetupId, lmsType, "Demo Quiz 11 (MOCKUP)", + "Starts in a minute and ends never", + DateTime.now(DateTimeZone.UTC).plus(Constants.MINUTE_IN_MILLIS) + .toString(Constants.DEFAULT_DATE_TIME_FORMAT), + null, + "http://lms.mockup.com/api/")); } @Override diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java index c5d335c2..5e4a4fb7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionControlTask.java @@ -161,7 +161,7 @@ public class ExamSessionControlTask implements DisposableBean { .getOrThrow() .stream() .filter(exam -> exam.startTime.minus(this.examTimePrefix).isBefore(now)) - .filter(exam -> exam.endTime != null && exam.endTime.plus(this.examTimeSuffix).isAfter(now)) + .filter(exam -> exam.endTime == null || exam.endTime.plus(this.examTimeSuffix).isAfter(now)) .flatMap(exam -> Result.skipOnError(this.examUpdateHandler.setRunning(exam, updateId))) .collect(Collectors.toMap(Exam::getId, Exam::getName)); diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/QuizDataTest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/QuizDataTest.java index f0d9f4a6..b1f7d465 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/QuizDataTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/QuizDataTest.java @@ -59,7 +59,7 @@ public class QuizDataTest extends AdministrationAPIIntegrationTester { }); assertNotNull(quizzes); - assertTrue(quizzes.content.size() == 8); + assertTrue(quizzes.content.size() == 9); // for the inactive LmsSetup we should'nt get any quizzes quizzes = new RestAPITestHelper() @@ -109,7 +109,7 @@ public class QuizDataTest extends AdministrationAPIIntegrationTester { }); assertNotNull(quizzes); - assertTrue(quizzes.content.size() == 8); + assertTrue(quizzes.content.size() == 9); // but for the now active lmsSetup2 we should get the quizzes quizzes = new RestAPITestHelper() @@ -120,7 +120,7 @@ public class QuizDataTest extends AdministrationAPIIntegrationTester { }); assertNotNull(quizzes); - assertTrue(quizzes.content.size() == 8); + assertTrue(quizzes.content.size() == 9); } @Test