diff --git a/src/test/java/de/tum/in/www1/artemis/entitylistener/ResultListenerIntegrationTest.java b/src/test/java/de/tum/in/www1/artemis/entitylistener/ResultListenerIntegrationTest.java index fe602b3564b4..cd3eedaaa1ea 100644 --- a/src/test/java/de/tum/in/www1/artemis/entitylistener/ResultListenerIntegrationTest.java +++ b/src/test/java/de/tum/in/www1/artemis/entitylistener/ResultListenerIntegrationTest.java @@ -4,9 +4,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -import java.time.Duration; +import java.time.Instant; import java.time.ZonedDateTime; import java.util.List; +import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.AfterEach; @@ -16,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.util.ReflectionTestUtils; import de.tum.in.www1.artemis.AbstractSpringIntegrationLocalCILocalVCTest; import de.tum.in.www1.artemis.course.CourseUtilService; @@ -92,8 +94,11 @@ void cleanup() { @BeforeEach void setupTestScenario() { + // Prevents the ParticipantScoreScheduleService from scheduling tasks related to prior results + ReflectionTestUtils.setField(participantScoreScheduleService, "lastScheduledRun", Optional.of(Instant.now())); + + ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 100; participantScoreScheduleService.activate(); - ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 50; ZonedDateTime pastReleaseDate = ZonedDateTime.now().minusDays(5); ZonedDateTime pastDueDate = ZonedDateTime.now().minusDays(3); ZonedDateTime pastAssessmentDueDate = ZonedDateTime.now().minusDays(2); @@ -103,7 +108,6 @@ void setupTestScenario() { idOfStudent1 = student1.getId(); // creating course Course course = courseUtilService.createCourse(); - Long idOfCourse = course.getId(); TextExercise textExercise = textExerciseUtilService.createIndividualTextExercise(course, pastReleaseDate, pastDueDate, pastAssessmentDueDate); idOfIndividualTextExercise = textExercise.getId(); Exercise teamExercise = textExerciseUtilService.createTeamTextExercise(course, pastReleaseDate, pastDueDate, pastAssessmentDueDate); @@ -422,7 +426,7 @@ private ParticipantScore setupTestScenarioWithOneResultSaved(boolean isRatedResu // Wait for the scheduler to execute its task participantScoreScheduleService.executeScheduledTasks(); - await().atMost(Duration.ofSeconds(30)).until(() -> participantScoreScheduleService.isIdle()); + await().until(() -> participantScoreScheduleService.isIdle()); var savedParticipantScores = participantScoreRepository.findAllByExercise(exercise); assertThat(savedParticipantScores).isNotEmpty();