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

Development: Fix issues with server test flakiness #9417

Merged
merged 35 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
542cca5
Skip generated gc.log.lock on zipping
ole-ve Oct 1, 2024
b07dd0a
Use compareTo over equals for time in PushNotificationDeviceConfigura…
ole-ve Oct 1, 2024
0c59fcd
Make verifyPush more specific to the actual message
ole-ve Oct 1, 2024
e9e96bc
Specify assertions in PushNotificationDeviceConfigurationCleanupServi…
ole-ve Oct 1, 2024
0c56efc
Specify websocket verification in QuizSubmissionIntegrationTest
ole-ve Oct 1, 2024
7a37b52
Ignore deleting of gc.log.lock in LocalVCIntegrationTest
ole-ve Oct 1, 2024
9392187
Retrieve current server session by username in LocalVCSshIntegrationTest
ole-ve Oct 1, 2024
fcd3880
Make testGetQueuedBuildJobs_returnsJobs dependent on previous number …
ole-ve Oct 1, 2024
3efe60c
Replace doReturn with thenReturn
ole-ve Oct 1, 2024
efe4ac8
Set unique hazelcast instance name for each abstract test setup
ole-ve Oct 1, 2024
7bd3cd3
Fix compilation error
ole-ve Oct 1, 2024
7001f15
Use individual test prefix for each subclass of AbstractLocalCILocalV…
ole-ve Oct 1, 2024
04cc52a
Fix unintended change
ole-ve Oct 1, 2024
908956a
Execute participant score tasks sync in testLatestSubmission
ole-ve Oct 1, 2024
ebebf90
Override LocalVCSshIntegrationTest#getTestPrefix from superclass
ole-ve Oct 1, 2024
e47ac99
Add CourseCompetency#equals
ole-ve Oct 1, 2024
877826e
Add timing to testPriority
ole-ve Oct 1, 2024
0e5ac15
Setup and cleanup scheduler for every LocalVCLocalCIIntegrationTest
ole-ve Oct 1, 2024
b3652e3
Execute ParticipantScoreScheduleService in testPriority
ole-ve Oct 1, 2024
2ec220d
Increase timeout of testPriority to 120s
ole-ve Oct 1, 2024
9f13f01
Rename testCannotFindResults to testResultsNotFound
ole-ve Oct 1, 2024
1587b1d
Setup and reset scheduler in LocalCIIntegrationTest
ole-ve Oct 1, 2024
3f0598a
Increase timeout of testCommitHashNull to 90 seconds for testing
ole-ve Oct 1, 2024
caf5fd1
Revert "Add CourseCompetency#equals"
ole-ve Oct 1, 2024
8361b79
Reset ParticipantScoreScheduleService lastScheduledRun before every run
ole-ve Oct 1, 2024
e9af0a0
Remove mocking of javaMailSender in individual test classes
ole-ve Oct 1, 2024
3951f0a
Add ToDo on CourseCompetency
ole-ve Oct 1, 2024
89f25a6
Move scheduling startup and teardown to AbstractArtemisIntegrationTest
ole-ve Oct 1, 2024
61988fa
Increase timeout for testCommitHashNull to 120 seconds
ole-ve Oct 1, 2024
f6d320c
Don't count SSH sessions that have no client session attached in Loca…
ole-ve Oct 3, 2024
d781859
Javadoc
ole-ve Oct 3, 2024
d3cec06
Logic?
ole-ve Oct 3, 2024
bca5dcc
Merge remote-tracking branch 'origin/develop' into chore/flakyness
ole-ve Oct 7, 2024
1ed4d48
Remove ToDo
ole-ve Oct 7, 2024
63b9708
Merge remote-tracking branch 'origin/develop' into chore/flakyness
ole-ve Oct 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public boolean equals(Object object) {
return false;
}
PushNotificationDeviceConfiguration that = (PushNotificationDeviceConfiguration) object;
return token.equals(that.token) && deviceType == that.deviceType && expirationDate.equals(that.expirationDate) && Arrays.equals(secretKey, that.secretKey)
// Use compareTo rather than equals for dates to ensure timestamps and dates with the same time are considered equal
// This is caused by Java internal design having different classes for Date (java.util) and Timestamp (java.sql)
return token.equals(that.token) && deviceType == that.deviceType && expirationDate.compareTo(that.expirationDate) == 0 && Arrays.equals(secretKey, that.secretKey)
&& owner.equals(that.owner);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
Expand Down Expand Up @@ -33,6 +34,12 @@ public class ZipFileService {

private final FileService fileService;

/**
* Set of file names that should be ignored when zipping.
* This currently only includes the gc.log.lock (garbage collector) file created by JGit in programming repositories.
*/
private static final Set<Path> IGNORED_ZIP_FILE_NAMES = Set.of(Path.of("gc.log.lock"));

public ZipFileService(FileService fileService) {
this.fileService = fileService;
}
Expand Down Expand Up @@ -113,7 +120,7 @@ private void createZipFileFromPathStream(Path zipFilePath, Stream<Path> paths, P
if (extraFilter != null) {
filteredPaths = filteredPaths.filter(extraFilter);
}
filteredPaths.forEach(path -> {
filteredPaths.filter(path -> !IGNORED_ZIP_FILE_NAMES.contains(path)).forEach(path -> {
ZipEntry zipEntry = new ZipEntry(pathsRoot.relativize(path).toString());
copyToZipFile(zipOutputStream, path, zipEntry);
});
ole-ve marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

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;
Expand All @@ -15,7 +13,6 @@
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.cit.aet.artemis.assessment.repository.ParticipantScoreRepository;
import de.tum.cit.aet.artemis.assessment.service.ParticipantScoreScheduleService;
Expand Down Expand Up @@ -60,11 +57,7 @@ class ExerciseScoresChartIntegrationTest extends AbstractSpringIntegrationIndepe

@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 = 50;
participantScoreScheduleService.activate();
ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(5);
userUtilService.addUsers(TEST_PREFIX, 3, 2, 0, 0);
Course course = courseUtilService.createCourse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

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;
Expand All @@ -15,7 +13,6 @@
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.cit.aet.artemis.assessment.domain.GradingScale;
import de.tum.cit.aet.artemis.assessment.dto.score.ScoreDTO;
Expand Down Expand Up @@ -98,11 +95,7 @@ class ParticipantScoreIntegrationTest extends AbstractSpringIntegrationLocalCILo

@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 = 200;
participantScoreScheduleService.activate();
ZonedDateTime pastTimestamp = ZonedDateTime.now().minusDays(5);
// creating the users student1, tutor1 and instructors1
userUtilService.addUsers(TEST_PREFIX, 1, 1, 0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

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;
Expand All @@ -17,7 +15,6 @@
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.cit.aet.artemis.assessment.domain.ParticipantScore;
import de.tum.cit.aet.artemis.assessment.domain.Result;
Expand Down Expand Up @@ -84,11 +81,7 @@ 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();
ZonedDateTime pastReleaseDate = ZonedDateTime.now().minusDays(5);
ZonedDateTime pastDueDate = ZonedDateTime.now().minusDays(3);
ZonedDateTime pastAssessmentDueDate = ZonedDateTime.now().minusDays(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class CourseCompetencyIntegrationTest extends AbstractCompetencyPrerequisiteInte
@BeforeEach
void setupTestScenario() {
super.setupTestScenario(TEST_PREFIX, course -> competencyUtilService.createCompetency(course, "penguin"));

participantScoreScheduleService.activate();
}

private Result createExerciseParticipationSubmissionAndResult(Exercise exercise, StudentParticipation studentParticipation, double pointsOfExercise,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anySet;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;

Expand Down Expand Up @@ -81,7 +80,6 @@ void init() {
exercise.setMaxPoints(5.0);
exerciseRepository.saveAndFlush(exercise);

doNothing().when(javaMailSender).send(any(MimeMessage.class));
sizeBefore = notificationRepository.count();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.MESSAGE_REPLY_IN_CONVERSATION_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.NEW_PLAGIARISM_CASE_STUDENT_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.PLAGIARISM_CASE_VERDICT_STUDENT_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_ASSIGNED_TEXT;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_ASSIGNED_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_DEREGISTRATION_STUDENT_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_DEREGISTRATION_TUTOR_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_REGISTRATION_MULTIPLE_TUTOR_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_REGISTRATION_STUDENT_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_REGISTRATION_TUTOR_TITLE;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_UNASSIGNED_TEXT;
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_UNASSIGNED_TITLE;
import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.NOTIFICATION_USER_NOTIFICATION_DATA_EXPORT_CREATED;
import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.NOTIFICATION_USER_NOTIFICATION_DATA_EXPORT_FAILED;
Expand All @@ -40,7 +42,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anySet;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.timeout;
Expand All @@ -63,6 +64,7 @@
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.springframework.beans.factory.annotation.Autowired;

import de.tum.cit.aet.artemis.assessment.domain.AssessmentType;
Expand Down Expand Up @@ -132,6 +134,12 @@ class SingleUserNotificationServiceTest extends AbstractSpringIntegrationIndepen
@Autowired
private ParticipationUtilService participationUtilService;

@Captor
private ArgumentCaptor<Notification> appleNotificationCaptor;

@Captor
private ArgumentCaptor<Notification> firebaseNotificationCaptor;

private User user;

private User userTwo;
Expand Down Expand Up @@ -263,8 +271,6 @@ void setUp() {

dataExport = new DataExport();
dataExport.setUser(user);

doNothing().when(javaMailSender).send(any(MimeMessage.class));
}

/**
Expand All @@ -273,8 +279,10 @@ void setUp() {
* @param expectedNotificationTitle is the title (NotificationTitleTypeConstants) of the expected notification
*/
private void verifyRepositoryCallWithCorrectNotification(String expectedNotificationTitle) {
Notification capturedNotification = notificationRepository.findAll().getFirst();
assertThat(capturedNotification.getTitle()).as("Title of the captured notification should be equal to the expected one").isEqualTo(expectedNotificationTitle);
List<Notification> capturedNotifications = notificationRepository.findAll();
assertThat(capturedNotifications).isNotEmpty();
List<Notification> relevantNotifications = capturedNotifications.stream().filter(e -> e.getTitle().equals(expectedNotificationTitle)).toList();
assertThat(relevantNotifications).as("Title of the captured notification should be equal to the expected one").hasSize(1);
Comment on lines +282 to +285
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM: Improved verification logic.

The changes to verifyRepositoryCallWithCorrectNotification method enhance the precision of the test by ensuring exactly one notification with the expected title is created. The use of streams improves readability.

Consider using assertThat(relevantNotifications).singleElement() instead of assertThat(relevantNotifications).hasSize(1) for a more expressive assertion.

}

/// General notify Tests
Expand Down Expand Up @@ -531,24 +539,24 @@ void testTutorialGroupNotifications_tutorDeregistration() {
@Test
void testTutorialGroupNotifications_groupAssigned() {
notificationSettingRepository.deleteAll();
notificationSettingRepository
.save(new NotificationSetting(tutorialGroup.getTeachingAssistant(), true, true, true, NOTIFICATION__TUTOR_NOTIFICATION__TUTORIAL_GROUP_ASSIGN_UNASSIGN));
User teachingAssistant = tutorialGroup.getTeachingAssistant();
notificationSettingRepository.save(new NotificationSetting(teachingAssistant, true, true, true, NOTIFICATION__TUTOR_NOTIFICATION__TUTORIAL_GROUP_ASSIGN_UNASSIGN));
singleUserNotificationService.notifyTutorAboutAssignmentToTutorialGroup(tutorialGroup, tutorialGroup.getTeachingAssistant(), userThree);
verifyRepositoryCallWithCorrectNotification(TUTORIAL_GROUP_ASSIGNED_TITLE);
verifyEmail();
verifyPush(1);
verifyPush(1, TUTORIAL_GROUP_ASSIGNED_TEXT, teachingAssistant);
ole-ve marked this conversation as resolved.
Show resolved Hide resolved

}

@Test
void testTutorialGroupNotifications_groupUnassigned() {
notificationSettingRepository.deleteAll();
notificationSettingRepository
.save(new NotificationSetting(tutorialGroup.getTeachingAssistant(), true, true, true, NOTIFICATION__TUTOR_NOTIFICATION__TUTORIAL_GROUP_ASSIGN_UNASSIGN));
User teachingAssistant = tutorialGroup.getTeachingAssistant();
notificationSettingRepository.save(new NotificationSetting(teachingAssistant, true, true, true, NOTIFICATION__TUTOR_NOTIFICATION__TUTORIAL_GROUP_ASSIGN_UNASSIGN));
singleUserNotificationService.notifyTutorAboutUnassignmentFromTutorialGroup(tutorialGroup, tutorialGroup.getTeachingAssistant(), userThree);
verifyRepositoryCallWithCorrectNotification(TUTORIAL_GROUP_UNASSIGNED_TITLE);
verifyEmail();
verifyPush(1);
verifyPush(1, TUTORIAL_GROUP_UNASSIGNED_TEXT, teachingAssistant);
}

@Test
Expand Down Expand Up @@ -579,9 +587,20 @@ private void verifyEmail() {
*
* @param times how often the email should have been sent
*/
private void verifyPush(int times) {
verify(applePushNotificationService, timeout(1500).times(times)).sendNotification(any(Notification.class), anySet(), any(Object.class));
verify(firebasePushNotificationService, timeout(1500).times(times)).sendNotification(any(Notification.class), anySet(), any(Object.class));
private void verifyPush(int times, String text, User recipient) {
verify(applePushNotificationService, timeout(1500).atLeast(times)).sendNotification(appleNotificationCaptor.capture(), anySet(), any(Object.class));
verify(firebasePushNotificationService, timeout(1500).atLeast(times)).sendNotification(firebaseNotificationCaptor.capture(), anySet(), any(Object.class));

List<SingleUserNotification> appleNotifications = filterRelevantNotifications(appleNotificationCaptor.getAllValues(), text, recipient);
assertThat(appleNotifications).as(times + " Apple notifications should have been sent").hasSize(times);

List<SingleUserNotification> firebaseNotifications = filterRelevantNotifications(firebaseNotificationCaptor.getAllValues(), text, recipient);
assertThat(firebaseNotifications).as(times + " Firebase notifications should have been sent").hasSize(times);
}

private List<SingleUserNotification> filterRelevantNotifications(List<Notification> notifications, String title, User recipient) {
return notifications.stream().filter(notification -> notification instanceof SingleUserNotification).map(notification -> (SingleUserNotification) notification)
.filter(notification -> title.equals(notification.getText()) && recipient.getId().equals(notification.getRecipient().getId())).toList();
ole-ve marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +601 to +603
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Rename parameter title to text for clarity

In the filterRelevantNotifications method, the parameter title is compared with notification.getText(). To avoid confusion between notification.getTitle() and notification.getText(), consider renaming the parameter to text to accurately reflect its purpose.

Apply this diff to rename the parameter:

-private List<SingleUserNotification> filterRelevantNotifications(List<Notification> notifications, String title, User recipient) {
+private List<SingleUserNotification> filterRelevantNotifications(List<Notification> notifications, String text, User recipient) {
    return notifications.stream()
-        .filter(notification -> title.equals(notification.getText()) && recipient.getId().equals(notification.getRecipient().getId()))
+        .filter(notification -> text.equals(notification.getText()) && recipient.getId().equals(notification.getRecipient().getId()))
        .toList();
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private List<SingleUserNotification> filterRelevantNotifications(List<Notification> notifications, String title, User recipient) {
return notifications.stream().filter(notification -> notification instanceof SingleUserNotification).map(notification -> (SingleUserNotification) notification)
.filter(notification -> title.equals(notification.getText()) && recipient.getId().equals(notification.getRecipient().getId())).toList();
private List<SingleUserNotification> filterRelevantNotifications(List<Notification> notifications, String text, User recipient) {
return notifications.stream().filter(notification -> notification instanceof SingleUserNotification).map(notification -> (SingleUserNotification) notification)
.filter(notification -> text.equals(notification.getText()) && recipient.getId().equals(notification.getRecipient().getId())).toList();

}

private static Stream<Arguments> getNotificationTypesAndTitlesParametersForGroupChat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import static de.tum.cit.aet.artemis.communication.domain.notification.NotificationConstants.TUTORIAL_GROUP_UPDATED_TITLE;
import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.NOTIFICATION__TUTORIAL_GROUP_NOTIFICATION__TUTORIAL_GROUP_DELETE_UPDATE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;

Expand All @@ -15,8 +13,6 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import jakarta.mail.internet.MimeMessage;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -86,7 +82,6 @@ void setUp() {
userRepository.findOneByLogin(TEST_PREFIX + "tutor1").orElseThrow(), IntStream.range(1, STUDENT_COUNT + 1)
.mapToObj((studentId) -> userRepository.findOneByLogin(TEST_PREFIX + "student" + studentId).orElseThrow()).collect(Collectors.toSet()));

doNothing().when(javaMailSender).send(any(MimeMessage.class));
tutorialGroupNotificationRepository.deleteAll();
notificationSettingRepository.deleteAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static de.tum.cit.aet.artemis.communication.service.notifications.NotificationSettingsService.NOTIFICATION__WEEKLY_SUMMARY__BASIC_WEEKLY_SUMMARY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -118,8 +117,6 @@ void setUp() {

exerciseRepository.saveAll(allTestExercises);
weeklyEmailSummaryService.setScheduleInterval(Duration.ofDays(7));

doNothing().when(javaMailSender).send(any(MimeMessage.class));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package de.tum.cit.aet.artemis.communication.service;

import static org.springframework.test.util.AssertionErrors.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -54,6 +53,7 @@ void cleanupTest() {

List<PushNotificationDeviceConfiguration> result = deviceConfigurationRepository.findByUserIn(Set.of(user), PushNotificationDeviceType.FIREBASE);

assertEquals("The result is not correct", Collections.singletonList(valid), result);
assertThat(result).contains(valid);
assertThat(result).doesNotContain(expired);
ole-ve marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static de.tum.cit.aet.artemis.core.util.TimeUtil.toRelativeTime;
import static org.assertj.core.api.Assertions.assertThat;

import java.time.Instant;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
Expand All @@ -20,7 +19,6 @@
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.cit.aet.artemis.assessment.domain.ParticipantScore;
import de.tum.cit.aet.artemis.assessment.repository.StudentScoreRepository;
Expand Down Expand Up @@ -84,10 +82,7 @@ class MetricsIntegrationTest extends AbstractSpringIntegrationIndependentTest {

@BeforeEach
void setupTestScenario() throws Exception {
// 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();

userUtilService.addUsers(TEST_PREFIX, 3, 1, 1, 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class StatisticsIntegrationTest extends AbstractSpringIntegrationIndependentTest

@BeforeEach
void initTestCase() {
participantScoreScheduleService.activate();
userUtilService.addUsers(TEST_PREFIX, NUMBER_OF_STUDENTS, 1, 0, 1);

course = modelingExerciseUtilService.addCourseWithOneModelingExercise();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ void setup() {
userTestRepository.save(instructor10);

ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 200;
participantScoreScheduleService.activate();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ void initTestCase() {
gitlabRequestMockProvider.enableMockingOfRequests();

ParticipantScoreScheduleService.DEFAULT_WAITING_TIME_FOR_SCHEDULED_TASKS = 200;
participantScoreScheduleService.activate();
}

@AfterEach
Expand Down
Loading
Loading